Passing Record Producer Variable to Script Include

JJG_SNOW
Mega Guru

I have 2 variables on a record producer. One is "account", the other is "contract".

Both are reference fields, customer_account & ast_contract.

 

Once the account is selected, I only want contracts related to that specific account to be shown on the contract reference variable. (There is an "account" field on the contract table)

 

I have done this before via calling a script include and passing the account variable and returning the sys_id's of the contracts I want to be shown in the contract variable:

JohnGilmore_1-1702499118297.png

 

The issue is I cannot pass record producer variables to the script include using this method for some reason.

Here are the errors:

com.glide.script.RhinoEcmaError: "current" is not defined.
<refname> : Line(1) column(0)
==> 1: new ProjectOverview().getAccountContracts(current.variables.account)
com.glide.script.RhinoEcmaError: "producer" is not defined.
<refname> : Line(1) column(0)
==> 1: new ProjectOverview().getAccountContracts(producer.variables.account)
com.glide.script.RhinoEcmaError: "producer" is not defined.
<refname> : Line(1) column(0)
==> 1: new ProjectOverview().getAccountContracts(producer.account)

 

As you can see producer.accountproducer.variables.account, and current.variables.account are not working.

How can I pass the record producer's account variable to the script include using reference qualifiers? (See first screenshot)

1 ACCEPTED SOLUTION

Tai Vu
Kilo Patron
Kilo Patron

Hi @JJG_SNOW 

Your first try is the correct one.

new ProjectOverview().getAccountContracts(current.variables.account)

 

The root cause is because of the way you set the Reference Qualifier. Let's try to modify as following below.

javascript&colon; "sys_id=" + new ProjectOverview().getAccountContracts(current.variables.account)

Screenshot 2023-12-14 at 11.04.34.png

 

Cheers,

Tai Vu

View solution in original post

3 REPLIES 3

Michael George
Tera Guru

Can you point it to g_form.getValue('account') ? Failing that, do an onChange script to run your script include?

malaviya
Kilo Expert

Do it using an On change client script and then pass the variable value to the script include.

Tai Vu
Kilo Patron
Kilo Patron

Hi @JJG_SNOW 

Your first try is the correct one.

new ProjectOverview().getAccountContracts(current.variables.account)

 

The root cause is because of the way you set the Reference Qualifier. Let's try to modify as following below.

javascript&colon; "sys_id=" + new ProjectOverview().getAccountContracts(current.variables.account)

Screenshot 2023-12-14 at 11.04.34.png

 

Cheers,

Tai Vu