How can a onSubmit catalog client script get data from one onChange catalog client script?

Student1
Tera Contributor

Hello,

I have an integration of SN with a third system.

I have a field: "Number" in a record producer. On this field I have set a on change catalog client script. So, every time that this value changes a rest api call is made to see if the number exists on the third system (I call a script include and the script include makes the call).

If so, another field "Description" is auto-populated with the data received from the third system. On the other hand, if it does not exist, an alert box pops up.

When the user submits the form, I want the number and the description to be inserted as new record on a custom table. For this, I can make a catalog client script on submit and call a script include to insert the new record.

However, for making this work, I need to take the description value that is fetched on the onchange client script.

Is there any way to make the onChange catalog client script to communicate with the onSubmit catalog client script?

In other words, my onSubmit catalog client script needs data from the onChange catalog client script.

Any ideas??

1 ACCEPTED SOLUTION

Hi,

it would take the latest value when your record producer script runs

So it would be 222 and BBB

var gr=new GlideRecord("u_custom_table");
gr.initialize();

gr.u_number = producer.number; // use valid number variable name here

gr.u_description = producer.description; // use valid description variable name here

gr.insert();

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Thanks Ankur!!

Hey Student 

Could You Please Help How did You configure the Rest One with Scripting ? 

 

Hey, 

I have a onChange catalog client script on my record producer.

From this script I send some data from the form (for example, number field), to the script include. Inside my script include, I receive the data and send them to the third system using RESTMessageV2(). 

Then, I get the response from the third system on my script include and pass it back to the catalog client script.

That's the logic.

abhi56
Tera Contributor

Can you pls give the exact coding ,if it is currently with you@student1