Parameter to String

Gal Katz
Kilo Sage

In Script-Include: I'm getting a parameter from Client-Script (I used g_form.getValue() on a String Choice Field to get the value and send it to Script Include).

I need to insert a string to the query but for some reason I can't convert the parameter to string (in addition to what is shown in the image below, I tried:    sec = u_sec_class.toString()     without success)

Please advise.

Screenshot_20221219_102458.png

 

1 ACCEPTED SOLUTION

Gal Katz
Kilo Sage

I'm updating that I instead of using the parameter I wrote a workaround and just used current.u_sec_class in the query.

View solution in original post

24 REPLIES 24

@Gal Katz in that g_form.getValue() is not returning you anything.

 

Please add an alert on top before GlideAjax call as below

alert(g_form.getValue('u_sec_class'));

 

if you don't get anything in alert then please check the value in that field.

 

If you get alert correctly then please store the value in some variable and then pass to glideajax as below

 

var secClass = g_form.getValue('u_sec_class');

 

then 

 

ga.addParam('u_sec_class', secClass.toString());

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Sorry for the delay. I was working on a more urgent project.
In the Client Script I do get the value, but in the Script Include when I get the parameter its undefined for some reason.
I also tired to store the value in some variable and then pass to GlideAjax as you advised but without success. 

@Gal Katz Please update the first parameter to addParam function as below this should definitely fix the issue.

The first parameter should start with sysparm_

 

ga.addParam('sysparm_sec_class', g_form.getValue('u_sec_class'));

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

sorry. same result.

@Gal Katz In script include have you used sysparm_sec_class in this.getParameter function?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023