Help

Updating a linked records through scripts automation

951 1
cancel
Showing results for 
Search instead for 
Did you mean: 
xXTMXx
5 - Automation Enthusiast
5 - Automation Enthusiast

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:

xXTMXx_0-1674026117432.png

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:

xXTMXx_1-1674026539800.png

xXTMXx_2-1674028145971.png

 

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.

1 Reply 1
ramonscardua
5 - Automation Enthusiast
5 - Automation Enthusiast

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]
...