Help

New Scripting API calls: Selecting records by recordId

Topic Labels: Scripting extentions
12137 13
cancel
Showing results for 
Search instead for 
Did you mean: 
Philip_Langdale
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi everyone!

I’m happy to announce that we’ve released a new scripting API capability today, and this is available in both the Scripting App and the ‘Run a script’ Automation action.

You can now select records by recordId, either by setting a new recordIds option when calling selectRecordsAsync or by using the new convenience method selectRecordAsync when you only need one record.

This will be especially useful in Automations, where you can now easily select a Record based on a trigger or Find Records output.

Examples:

const recordIds = input.config().recordIds;
const table = base.getTable('Team');
const recordsResult = await table.selectRecordsAsync({fields: table.fields, recordIds});
const records = recordsResult.records;
for (const record of records) {
    console.log(`Record name: ${record.name}`);
}

and

const recordId = input.config().recordId;
const table = base.getTable('Team');
const record = await table.selectRecordAsync(recordId);
if (record) {
    console.log(`Record name: ${record.name}`);
}

We hope this new capability will help you with your scripts!

Thanks!

13 Replies 13
Wichie_Artu1
5 - Automation Enthusiast
5 - Automation Enthusiast

I’ve only been getting ID and Name with this function. Advice?

//Get Client ID 
let inputConfig = input.config()
let id = inputConfig.id[0]

//Get Client Information
let table = base.getTable("Clients")
  console.log(table.fields)
let record = await table.selectRecordAsync(
  id
  //,{fields: ["Name","Long Name","Address"]}
  )
  console.log(record)

image

Uncomment your array of fields that you want returned. Then use record.getCellValue() to get the data.

Thank you. This answer in conjunction with this forum was helpful.

Basically, the “record” variable in my code is a reference to the query and not the record itself. I have to GET the value of the specific field to return the field value

Here’s my new code…

//Get Client ID 
let inputConfig = input.config()
let id = inputConfig.id[0]

//Get Client Information
let table = base.getTable("Clients")
  console.log(table)
let query = await table.selectRecordAsync(
  id
  ,{fields: ["Name","Long Name","Address"]}
  )
  console.log(query.getCellValue("Name"))

//Return Client Information
output.set("clientName",query.getCellValue("Name"))
output.set("clientLongName",query.getCellValue("Long Name"))
output.set("clientAddress",query.getCellValue("Address"))

Hi @Philip_Langdale 

I've noticed the sorts option becomes redundant when using the recordIDs option in the selectRecordsAsync method. Is there any chance that this could be supported in the future? I'm really hoping it can be done...

If not, could the API help documentation at least be updated to note this limitation?