Help

Lookup Value in Link field and add filter based on two values

Topic Labels: Scripting extentions
1057 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Jeremy_Martin
6 - Interface Innovator
6 - Interface Innovator

Hi there

I’m new to automation scripting and would appreciate some help

I start my app with a trigger when a record is added to a table.

How can I use (reference) the fields from the trigger record in my script?

Trigger return a record with the name of a city

I want to query another table inside my script and find all the records with that city and then do some other calculations based on the records returned from the query.

Please let me know how to do it, and if possible, where can I get some ‘more advanced’ examples

1 Reply 1

This is done by using input variables. When editing the script in the “Run script” action in the automation, the left panel will be where you see and edit input variables. Click “+ Add input variable” to add one. The top part is where you choose the variable name, and the bottom part is where you choose a value from a previous action (or the trigger) to assign to that variable.

In the script, there are a couple of ways to access these input variables, but they all start with accesing input.config(). One method is to assign them all collectively to a single helper variable, and then access them from there. For example, say that you created an input variable named “city”. At the top of your script, you could do this:

const inputVariables = input.config()

Then where you need to access the value of “city”, you would do something like this:

if (record.getCellValue("City") === inputVariables.city) {
    ...
}

A more abbreviated method is to directly assign all input variables to their own unique variables in one shot at the start of your script:

const {city} = input.config()

Then later you can directly use “city” like so:

if (record.getCellValue("City") === city) {
    ...
}