Help

Re: updateRecordAsync error in an Automation

2115 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Emad_Aboelela
4 - Data Explorer
4 - Data Explorer

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:

6 Replies 6

What values are you trying to update, are any of those fields calculated (i.e. formulas, rollups, lookups, …)?

Emad_Aboelela
4 - Data Explorer
4 - Data Explorer

A “Single Select” field.

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" }}
Emad_Aboelela
4 - Data Explorer
4 - Data Explorer

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.

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

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]});
		}
}