Help

Creating and prepopulating records with a script

Topic Labels: Scripting extentions
929 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Jessica_Plautz
4 - Data Explorer
4 - Data Explorer

I have a script (adapted from a template) to create a new project in one tab, and a list of associated tasks in another tab.

What I’d like to do is add another input where the user provides a project launch date, and then have dates for all the tasks that build off of that initial date (preferably + a specific number of workdays, as a function might do in Excel). I’m not sure what to use for the input (I’m new to JS) so that the user can enter a date in MM/DD/YYYY format, and I’m also unclear how/if I might user formulas within the task creation to have sequential dates. Anyone have any suggestions?

// pick tables from your base here
let projects = base.getTable(‘Projects’);
let tasks = base.getTable(‘Tasks’);
// prompt the user to pick a template for our project
output.markdown(’# New Project and Tasks’);
let name = await input.textAsync(‘Project name’);
// create the project - change the field name to one in your base
let projectId = await projects.createRecordAsync({
‘Project’: name,
});
// create the tasks - change the field names to ones from your base.
// the [{id: projectId}] links the newly created records back to our project
await tasks.createRecordsAsync([
{
fields: {
‘Task’: ‘A first task’,
‘Campaign’: [{id: projectId}],
},
},
{
fields: {
‘Task’: ‘Another task’,
‘Campaign’: [{id: projectId}],
},
},
{
fields: {
‘Task’: ‘A final task’,
‘Campaign’: [{id: projectId}],
},
}
])
output.text(‘Project and tasks created.’);// JavaScript Document

0 Replies 0