Help

Automation Scripting Error - Field cannot accept provided value

Topic Labels: Scripting extentions
14187 22
cancel
Showing results for 
Search instead for 
Did you mean: 
Megan_Ecclesto1
6 - Interface Innovator
6 - Interface Innovator

Not sure why I keep getting an error message when I try to automate this script:
Error
I just need the first 5 digits of the Project code pasted into the 5 digit (linked) column. If it doesn’t already exist, it needs to create a new record.
Help?

22 Replies 22

Hey Dominik,

Seems that I’m having the same issue as Nicholas has covered above. The fault is raising on the updateRecordAsync. I use the same code in other automation flow but haven’t found the same issue. May it be related to the size of the array?

let inputConfig = input.config();
let recordId = inputConfig.recordId
let country = inputConfig.country
let chargeId = inputConfig.chargeId

let country_code = inputConfig.countryCode

let country_table = base.getTable('Country')
let q = await country_table.selectRecordsAsync()
for (let record of q.records) {
    if (record.name == country_code) {
        
        let cache = record.getCellValue("Payments")
        let charge = [...cache]
        charge.push({id: recordId, name:chargeId})
        await country_table.updateRecordAsync(record, {
            Payments:charge
        })
        
        // This one didn't work either.     
        // let arr = [{id: recordId, name:chargeId}]
        // await country_table.updateRecordAsync(record, {
        //     Payments:[...record.getCellValue("Payments"), ...arr]
        // })
    }
}

This may be the problem. When setting something that has both an ID and a name, it’s best to use one or the other, but not both. In theory it shouldn’t be a problem to use both properties, but if one property will do the job, then there’s no point in adding the second one. It doesn’t do anything that the first one doesn’t do, so I suggest leaving it out.

Welcome to the community, Dany!

I agree with Justin and would like to suggest you try simplifying your code a bit as these sticky situations are best avoided instead of debugged.

For example, you could declare your cache array outside of the for…of loop, use the loop to fill it with records like so:

externalCache.push({id:record.id,{Payments:record.getCellValue('Payments')}})

Then update them all at once by doing:

while (externalCache.length) await country_table.updateRecordsAsync(externalCache.splice(0,50))

In this case, you’d be left with roughly two-thirds of your original source code while accomplishing the same task more quickly (especially if you’re dealing with a lot of data). Speed aside, fewer lines of code means fewer opportunities to make mistakes.

In the meantime, see if that final part of your code works on its own by giving it a single recordId to update manually. I’m also not following the charge/cache logic - why the destructuring? If that’s a linked record field, the getCellValue method alread returns an Array by default.

Not a chance IMO. What kind of error is the code throwing, or is it simply not doing anything perceivable?