Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Apr 03, 2022 04:16 AM
Hallo,
i have a problem with the script.
i would like a template with next actions for a project with record picker function.
but the problem is with my script, i have two projects with the same name always after the script.
one project is empty and one projects with the template actions.
Problem is the projectid var. The script create always a new record.
Can someone help me pls with the syntax?
// pick tables from your base here
let projects = base.getTable(‘Projekte’);
let tasks = base.getTable(‘Next Action’);
// prompt the user to pick a template for our project
output.markdown(’# New project’);
let record = await input.recordAsync(‘Select a record to use’, projects);
if (record) {
// Customize this section to handle the selected record
// You can use record.getCellValue(“Field name”) to access
// cell values from the record
output.text(You selected this record: ${record.name}
);
let projectId = await projects.createRecordAsync({
‘Projekte’: record.name,
});
await tasks.createRecordsAsync([
{
fields: {
‘Next Action’: ‘The first task’,
‘Projekte’: [{id: projectId}],
},
},
{
fields: {
‘Next Action’: ‘Another task’,
‘Projekte’: [{id: projectId}],
},
},
{
fields: {
‘Next Action’: ‘The final task’,
‘Projekte’: [{id: projectId}],
},
}
])
output.text(‘Done!’);
} else {
output.text(‘No record was selected’);
}
Solved! Go to Solution.
Apr 04, 2022 09:12 AM
hi @mkay232,
the problem you are facing here is that you are using as project id the id of the new project that the script is creating. Basically the script creates a new project and then creates the tasks with as connected project the one you just created. What you instead want, is to have the script select an existing project and then add the id of that project to the new tasks you create.
To do that replace this:
let projectId = await projects.createRecordAsync({
‘Projekte’: record.name,
});
with
let projectId = record.id
Hope this helps!
Website: alessiomonino.com
Calendly: Calendly - Alessio Monino
Email: alessio.monino@gmail.com
Apr 04, 2022 09:12 AM
hi @mkay232,
the problem you are facing here is that you are using as project id the id of the new project that the script is creating. Basically the script creates a new project and then creates the tasks with as connected project the one you just created. What you instead want, is to have the script select an existing project and then add the id of that project to the new tasks you create.
To do that replace this:
let projectId = await projects.createRecordAsync({
‘Projekte’: record.name,
});
with
let projectId = record.id
Hope this helps!
Website: alessiomonino.com
Calendly: Calendly - Alessio Monino
Email: alessio.monino@gmail.com