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
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
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