Skip to main content
Answer

When record enters view, change status of linked records

  • June 16, 2021
  • 2 replies
  • 28 views

Hey guys and girls.

Do anyone know of a way to change the status/state of linked records when a record enters a view?

Best answer by Kamille_Parks11

Yep. You could use a Lookup field to show the “main” record’s status in all the linked records, or use an Automation script to update one field(s) in each of the linked records.

That script would pull in the linkedIds as an input config variable and would look something like so:

let table = base.getTable("Name of table where the linked records are")
let {linkedRecordIds} = input.config()
// Add items to the object "template" for each field that needs to be updated
// In this example there is a single select field named "Status" that is getting updated to the option "Pending". 
// Follow the scripting documentation for the correct format to use for the type of field you're updating
let template = {
    "Status": {name: "Pending"}
}

let updates = linkedRecordIds.map(id => {
    return {
        id: id,
        fields: {...template}
    }
})

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}

2 replies

Kamille_Parks11
Forum|alt.badge.img+27

Yep. You could use a Lookup field to show the “main” record’s status in all the linked records, or use an Automation script to update one field(s) in each of the linked records.

That script would pull in the linkedIds as an input config variable and would look something like so:

let table = base.getTable("Name of table where the linked records are")
let {linkedRecordIds} = input.config()
// Add items to the object "template" for each field that needs to be updated
// In this example there is a single select field named "Status" that is getting updated to the option "Pending". 
// Follow the scripting documentation for the correct format to use for the type of field you're updating
let template = {
    "Status": {name: "Pending"}
}

let updates = linkedRecordIds.map(id => {
    return {
        id: id,
        fields: {...template}
    }
})

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}

Yep. You could use a Lookup field to show the “main” record’s status in all the linked records, or use an Automation script to update one field(s) in each of the linked records.

That script would pull in the linkedIds as an input config variable and would look something like so:

let table = base.getTable("Name of table where the linked records are")
let {linkedRecordIds} = input.config()
// Add items to the object "template" for each field that needs to be updated
// In this example there is a single select field named "Status" that is getting updated to the option "Pending". 
// Follow the scripting documentation for the correct format to use for the type of field you're updating
let template = {
    "Status": {name: "Pending"}
}

let updates = linkedRecordIds.map(id => {
    return {
        id: id,
        fields: {...template}
    }
})

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}

Thanks alot, the lookup field was just the solution i was looking for, quick and easy to use.