Select Record by Record ID

Viewing 2 reply threads
  • Author
    Posts
  • June 12, 2023 at 6:51 AM #49578

    Pinny Berlin
    Participant

    Hello,

    I am trying to reference a specific record in my form by its ID. I was able to obtain the ID via this script:

    console.log(record.getId()); // returns ‘rec-6ca7e23ae2e44a2b94193cf0c8644ff6’

    Now I want to reference that record in my other scripts. For instance, that record has a field called location. I was hoping to reference it using the following code, but I get an error:

    aRecord = form.selectRecord("rec-6ca7e23ae2e44a2b94193cf0c8644ff6"); //record id of Current Location
    location = aRecord.getFieldValue('fld-5dc7a719a9ee49b4b0536be6fdffeb46');

    But it throws the error:

    TypeError: Argument does not match

    Objective-C Class, line:(null)

     

    I’m sure there’s a simple way to accomplish what I need (short of looping through each form record and checking the Id. Any help is appreciated!

    Thanks,

    Pinny

    June 12, 2023 at 6:58 AM #49579

    Pinny Berlin
    Participant

    Ugh! Two seconds after posting this, I found the JavaScript API doc and it listed the function I needed – getFieldWithId().

    Sorry to waste everyone’s time. But I’m happy I discovered the API doc, and hopefully I can use it to avoid asking questions like this in the future. :)

    Thanks,

    Pinny

    June 12, 2023 at 12:48 PM #49580

    Brendan
    Keymaster

    Hi Pinny,

    I’m glad you found the solution!

    The form.selectRecord() function is only used to tell the user interface to select a record. Not to actually get the record. For that you use form.getRecordWithId(record_id);

    Thanks!

    Brendan

Viewing 2 reply threads

You must be logged in to reply to this topic.