- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 27, 2021 09:49 AM
Hello Community!
I’d love some guidance on a script error that I am receiving while updating a record.
I have a table that gets refreshed every day with physician work shift data. The refreshed records contain the physician’s NPI value (single line text) as a text field and I want to populate NPI Reference (Linked field) with this same NPI value using a scheduled automation script.
When I run my script, I receive this information:
CONSOLE.LOG
“Copying NPI 1316340000 into record id recHQVgBpFoVSezTP”
ERROR
Error: Field “NPI Reference” cannot accept the provided value.
at main on line 12
Here’s my script:
let Shifts = base.getTable(“Shift Schedules”);
let shift = await Shifts.selectRecordsAsync();
// loop through the records
for (let record of shift.records)
{
if (record.getCellValue(“NPI Reference”) == null)
{
let recordID = record.getCellValue(“Record ID”);
console.log(Copying NPI ${record.getCellValue("NPI")} into record id ${recordID}
);
await Shifts.updateRecordAsync(recordID, {
"NPI Reference": record.getCellValue("NPI")
})
}
}
Thank you for your help!
Doug
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 30, 2021 08:07 AM
Good morning Kamille - No, the {NPI} field does not include “rec…”. Here’s an example:
“Record id rec004jYbE8Tsmf9k, NPI:1184159147”
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Apr 30, 2021 09:05 AM
Well then you’re going to have to get a list of all the records in the [NPI]
table, and filter for the one where the primary field equals the value of record.getCellValue("NPI")
, which would look something like this:
let NPItable = base.getTable("Table Name")
let NPIquery = await NPItable.selectRecordsAsync()
let match = NPIquery.records.find(x => x.name == record.getCellValue("NPI"))
if (match) {
await Shifts.updateRecordAsync(recordID, {
"NPI Reference": [{id: match.id}]
})
}
}
- « Previous
-
- 1
- 2
- Next »