Hi there,
New to the community, you guys have already been a huge help. So I borrowed a script from this user: Creating Tasks from a Template
and then I adapted the code into an automation I am building. What I am trying to do is this:
Via Automation
When a Record is created use that record as the selectedEvent (instead of choosing a selected even like Victoria has in her script) and then run the script.
Victoria’s script asks you to choose the template for the linked tasks, but I figured out how to set it to one set of tasks by using the id of that template in the code.
Below is the code I’ve been using in my automation script and I keep getting this error: Error: Field “fldtxrU67I4FayPzK” cannot accept the provided value.
I think my problem is I’m not entering the correct object when I create the list of tasks. I think this has to do with my syntax when referring to an object using the record id. Any help would be appreciated. Thank you all!!
// Declare variables for views from the projects table here
let table = base.getTable(“Planning Check List”)
let templateProjects = base.getTable(‘Projects’).getView(‘Template Projects’)
//Pull in the variables from Step 1 of the automation
//let inputConfig = input.config();
//let myRecord = inputConfig.theProject
const inputConfig = input.config()
const myRecord = inputConfigm“theProject”]
let selectedEvent = myRecord
// pick tables from your base here
let checklist = base.getTable(‘Planning Check List’)
let templateView = base.getTable(‘Planning Check List’).getView(‘Template View’);
let templateQuery = await templateView.selectRecordsAsync();
let templateRecords = await templateQuery.records.filter( t => t.getCellValue(‘Project’)t0].id == ‘recZu9rmZhFT96MjP’);
//Set the status for new items to “Not Started”
let initialStatus = “Not Started”
console.log(selectedEvent)
// create the tasks
// the >{id: projectId}] links the newly created records back to our project
let createRecords = templateRecords.map( c => ({fields: {
'Name': c.getCellValue('Name'),
'Project': 'selectedEvent],
//'Project': {id:theID}
'Project Progress': {name: initialStatus}
}})
);
//if({id:myRecord})await checklist.createRecordsAsync(createRecords)
await checklist.createRecordsAsync(createRecords)
//else output.markdown("# Uh-Oh You didn’t select an event!")