Jan 17, 2023 11:56 PM
Hello Everyone, i built a script for automating creating tasks for our team for the new leads you can found it on (Automate Task Creation in projects via a script). Now i tried to update linked records and other fields but faced below error:
"Error: Field "xxxxxxxxxxxxxxxxxxxx" cannot accept the provided value.
below is the table that should be updated based on the script that I'm trying to create:
and here's the script:
let lead = input.config();
// Find template action items
let templateActionItemsTable = base.getTable("[HIDE] Action Items");
let allTemplateActionItems = await templateActionItemsTable.selectRecordsAsync({fields: templateActionItemsTable.fields});
let templateActionItems = allTemplateActionItems.records.filter(templateActionItem => {
// check wether action items matching request
return templateActionItem.getCellValueAsString("Stages") === lead.stageName;
})
// create template action items in work items table
let actionItems = templateActionItems.map(templateActionItem => {
return {
fields: {
"action-item": templateActionItem.getCellValue("Action Items"),
"Stage": {
name: lead.stageName
},
"Lead": [{
id: lead.recordId
}],
"Assignee": [
{id: lead.assigneeId},
]
}
}
})
let workItemsTable = base.getTable("Work Items");
await workItemsTable.createRecordsAsync(actionItems);
and here's the inputs:
what i want to add/update in addition to (Lead, Assignee) is the following:
(( Due Date (date), Due Date (date) + Formula, Completed (checkbox) ))
* Due Date (date) + Formula: what I meant by this is that I want to manipulate the date based on a formula.
Jan 24, 2023 04:13 AM
Hi, im learning Airtable scripting, but I think you cannot use id here:
"Lead": [{
id: lead.recordId
}],
"Assignee": [
{id: lead.assigneeId}
try to use:
name: [name_primary_field]
...