ClientScript - onSubmit() I want to get the value of a reference field.

Takumi Togashi
Tera Expert

Hi,

 

I am thinking of an onSubmit catalog client script that gets another value for that field from a variable of type reference.

I tried the following script, but could not do it.
Please let me know the solution.

 

//"variables_name" contains variables of the catalog item's reference type.

var result = g_form.getReference(variables_name, function(user) {
g_form.getValue(user.user_name);
});

 

 

Thanks.

13 REPLIES 13

@Ankur Bawiskar 

The requirements were indeed unclear.

It is to get another value (user_name) for the field from a variable of the catalog item's reference type in onSubmit and store it in a variable (result) for use as a subsequent process.

@Takumi Togashi 

if the ask is to auto-populate another variable based on 1st variable then you should use onChange client script and not onSubmit

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Sorry. The wording was misleading.
The variable (result) here is not a catalog item variable.
It is a variable created temporarily for use within the catalog client script.

@Takumi Togashi 

so what is the result ?

Very difficult to understand without the screenshots.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

"result" is a variable created in the script as follows.
In this case, I named it "result," but it can be anything.

 

This may not be a good example, but this is the image you want to use in subsequent processing, such as displaying this value in an error message.

 

キャプチャ - コピー.PNG