Help

Re: Cant update record with linked field

1044 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Harold_Arriola_
4 - Data Explorer
4 - Data Explorer

Hello. I am having some trouble updating a field in my record with a linked field from another table. Here is what I have so far:

Lets say the creative record exist its just not linked

  if (creativeRecord) {
    return creativeRecord.id;
  }

I put the return of this function above ^ in the variable creativeRecordID that I use below. The value of creativeRecordID is a string “RecordQueryResult.1234”

  table.updateRecordAsync(record, {
    Creative: [{ id: creativeRecordID }],
  });

This is returning the error:
Can’t set cell values: invalid cell value for field ‘Creative’.
Cell value has invalid format: .0.0.id must be an objectId.

Any suggestions / solutions appreciated, Thanks!

3 Replies 3

This is not a valid record ID. A record ID takes the form of rec followed by 14 characters. To see actual record IDs, create a formula field with the function RECORD_ID().

Thanks, yea shortly after posting this I figured that must be the case. Is there anyway to do something like this:

  const lookupCreative = base("LookupCreative");
  const [creativeRecord] = await lookupCreative
    .select({ filterByFormula: `Hash="${hash}"`, fields: [] })
    .all();

We are currently moving a process that we wrote using the REST API, over to using a custom extension with scripting. And I currently have this:

  const creativeRecord = await lookupCreative.selectRecordsAsync({
    fields: ["Hash"],
  });

But is there is any better way to get a record id based on if the hash of the record matches the hash we create in code?

The REST API / Web API has some significant differences from Custom Extensions.

On the other hand, retrieving and processing records in Custom Extensions is very similar to Scripting Extension. And Scripting Extension is much simpler to use than Custom Extensions.

I suggest that you look at the Scripting documentation and learn the methods and features (and lack of features) in Scripting before applying that logic to a Custom Extension.

For example, both Custom Extensions and scripting have these features

  • no filter by formula; all filtering needs to be done in JavaScript after you get the records
  • a “query result” object
  • singular and batch methods for CRUD operations