Aug 05, 2020 09:34 AM
Hi,
I am trying to run a script through an Automation. The Automation is triggered by records entering a view. I receive the following error on a line that does updateRecordAsync:
Error: You are not permitted to perform this operation
I am not sure why because updateRecordAsync is used in the example provided here:
Aug 05, 2020 10:31 AM
What values are you trying to update, are any of those fields calculated (i.e. formulas, rollups, lookups, …)?
Aug 05, 2020 10:56 AM
A “Single Select” field.
Aug 05, 2020 11:41 AM
Here are some things to consider:
Does your code for updating the record run in Scripting block? (You may need to do slight adjustments for getting the inputs.)
Are you able to edit the field manually in the regular user interface? (If not, this indicates a permissions error.)
Do you have the correct “write format” for a single select?
To update a single select field, you need to pass an object with the string value, not just the string value itself.
Instead of
{"fieldName": "my single select value" }
try
{"fieldName": { name: "my single select value" }}
Aug 05, 2020 12:17 PM
The same script works fine in Scripting block.
I can update the filed manually and I am using the correct code for updating single select field.
Aug 14, 2020 09:48 PM
Would you be able to share your code here? That would give us a more clear picture of what’s happening, and allow us to help you solve this. When pasting the code, please wrap it in pairs of lines containing triplets of the “grave” character: `
For example, if you enter this into the editor:
```
insert
code
here
```
… it becomes…
insert
code
here
Aug 15, 2020 06:17 AM
Here you are the code:
//Query Registered Students table
let regStudentsTable = base.getTable('Registered Students');
let regStudentsQuery = await regStudentsTable.selectRecordsAsync();
let registeredIDs = [];
let registeredSECs = [];
let registeredInstructors = [];
for (let regRecord of regStudentsQuery.records) {
let enrollmentID = regRecord.getCellValue('Enrollment ID');
registeredIDs.push(enrollmentID);
registeredSECs.push(regRecord.getCellValue('Section'));
registeredInstructors.push(regRecord.getCellValue('Instructor'));
}
//Query Shipping table
let shippingTable = base.getTable('Shipping');
let statusView = shippingTable.getView('Empty Status');
let shippingQuery = await statusView.selectRecordsAsync();
for (let shpRecord of shippingQuery.records)
{
let shippingID = shpRecord.getCellValue('Shipping ID');
let regIndex = registeredIDs.indexOf(shippingID);
if (regIndex<0) //not registered
{
await shippingTable.updateRecordAsync(shpRecord.id,
{'Status':{name: 'Not Registered'}});
}
else{ //Registered and not duplicate
await shippingTable.updateRecordAsync(shpRecord.id,
{'Status': {name: 'Registered'},
'Lab Course Section':registeredSECs[regIndex],
'Lab Course Instructor':registeredInstructors[regIndex]});
}
}