Help

Re: Adding Tasks from one Table into Another Table - field labeling

613 0
cancel
Showing results for 
Search instead for 
Did you mean: 
GJ_Sequeira
4 - Data Explorer
4 - Data Explorer

I’m using code found from this post and am struggling to figure out how to get past an error of “Error: Field “fldJl8IjqgJizFULv” cannot accept the provided value.
at main on line 29”

The goal:

Separate a list of records into separate records to input into another table along with assigning fields of “Projects” and “Status”

What I’ve tried:

I’ve performed the script successfully with creating a record with the task name for each task, but when I try to define other fields I end up getting the error mentioned above.

Here’s my code so far. Any help is appreciated! I’m so close to getting this, just need a bit of help to the finish line

console.log(Hello, ${base.name}!);
let inputConfig = input.config();
console.log(The value of ProjectType is ${inputConfig.ProjectType});
console.log(The value of ClientName is ${inputConfig.ClientName});
console.log(The value of TaskName is ${inputConfig.TaskName});

// pick tables from your base here
let projects = base.getTable(‘Projects’);
let tasks = base.getTable(‘Shop Tasks’);

// define input variables
let TaskName = inputConfig.TaskName
let ProjectType= inputConfig.ProjectType
let ClientName = inputConfig.ClientName

// create the tasks - change the field names to ones from your base.
// Split records in find records step into separate tasks

let updates = new Array

for (let i = 0; i < TaskName.length; i++){
updates.push({
fields:{
“Name”: TaskName[i],
“Status”: “Todo”,
“Projects”: ProjectType + “-” + ClientName,

    }
})

}

while (updates.length > 0) {
await tasks.createRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}
console.log('The value of tasks is ',tasks)

5 Replies 5

Hmm, is your Status field a single select?

If so, I think you need to change the line

"Status": "Todo",

to

"Status": { name: "Todo" }

If it isn’t, could I know what types the Name, Status and Projects fields are so that I can help with the debugging?

Status is a single select and it works with either formatting (I’ve tried both haha)

Projects is a linked field - so not sure what I need to do in order to get it to be input correctly and without an error

GJ_Sequeira
4 - Data Explorer
4 - Data Explorer

I’ve tried another method of doing it outside the automation and in the scripting app, but end up getting a “possibly null” error in my code too

// select project
// understand what type of project it is
// user input which project needs action item

let projects = base.getTable(“Projects”);
let projectsView = projects.getView(“Projects Without Shop Tasks”);

let project = await input.recordAsync(“Select project to create tasks for”,projectsView);

console.log(project);

// find the action item templates

// load all template items
let templateItemsTable = base.getTable(“Sample Checklists”);
let alltemplateItems = await templateItemsTable.selectRecordsAsync();

console.log(alltemplateItems);

let templateItems = alltemplateItems.records.filter(templateItem => {
console.log(templateItem.getCellValue(“Task Checklist”));
return templateItem.getCellValueAsString(“Task Checklist”) === project.getCellValueAsString(“Project Type”)
});

console.log(templateItems);

// duplicate those templates into live action item

Here’s a screenshot of the error

Xnapper-2022-08-12-10.09.53

Ah, yes, this gets complicated. I assume the trigger for this automation is the creation of at ask in the Projects table, and you want the created tasks to be linked back to this record? If so, you’ll need to set up the record ID of the triggering record in the input variables and maybe set it up like so:

let triggeringRecordId= inputConfig.triggeringRecordId

And then also change the following line:

 “Projects”: ProjectType + “-” + ClientName,

to:

 “Projects”: [{id: triggeringRecordId}]

If you like, you can duplicate your base into a free workspace and invite me to it and I’ll just set it up for you real quick

Yeah, it’s just a warning that that value might not exist, but it’s definitely going to exist in the case of your code. When you run the code it runs alright?