OnSubmit catalog client script not working

krithvik
Mega Contributor

Hi All,

I am working in requirement that one variable should populate based on different conditions(Like location,BU and country  ect )  depends on catalog form.

I have written script included and OnSubmit catalog client script, Here I am getting logs and alerts correctly. But same value not populating in variable.

Note: This variable calling from variable set.

 

can anyone help me on this ,Tanks in advance.

 

Thanks,

Krithvik.

 

 

2 REPLIES 2

Willem
Giga Sage
Giga Sage

Hi Krithvik,

Can you share more information on this? Add a screenshot of your item for example. Can you share the scripts? Your title says onSubmit, but description onChange.

If it is onSubmit where you are having issues, have a look at this article:

https://community.servicenow.com/community?id=community_article&sys_id=e37f2072db9fd0103daa1ea668961...

 

In short, you need either synchronous getXMLWait ajax call or the alternative provided in the article.

 

This variable calling from variable set.

Is the Catalog client script also on the variable set? Is it a Multi Row Variable Set?

Hitoshi Ozawa
Giga Sage
Giga Sage

It's not possible to populate a variable in the main form from a client script in a mrvs. Also, there's no onChange on a mrvs. Unfortunately, GlideAjax is asynchronous so using it in onSubmit will result in the form being submitted before value from GlideAjax is returned to the client script.

It is, however, possible to fetch values in the mrvs from the client script in the main form. Redesign the form so there is no GlideAjax call in onSubmit. For example, having a hidden field in mrvs that is populate by GlideAjax call within mrvs do onSubmit in the main form will be able to validate on the hidden field value in the mrvs.

Check Harshvardhan's response in the following thread on accessing variables in mrvs. Basically, it's just doing a JSON.parse('<mrvs name>') and looping through the rows.

https://community.servicenow.com/community?id=community_question&sys_id=2b486d031be64c10a59033f2cd4b...