Script Include not returning expected result to on change client script?

KM SN
Tera Expert

I have few reasons where different reasons belongs to different finding so i am taking priority values of each reason and trying to figure out Highest priority (1 is high priority value) based on it i am setting the value of finding choice. 

 

but info message showing nothing ? need assistance!CS-dp.PNGSI-dp.PNG

1 ACCEPTED SOLUTION

@KM SN 

 

You need to test your code by changing the reasons field on the form.

After that go system logs>All>Search with TEXT2>it will show values of array if there is any value.

Share that screenshot

 

Also ,in your client script replace getXMLAnswer() with getXML(showDetails) add below code in your function

 

function showDetails(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    alert(answer);
    g_form.setValue('findings', anwer);
}

 

 

Thanks,

Manjusha Bangale

View solution in original post

7 REPLIES 7

SwarnadeepNandy
Mega Sage

Hello @KM SN,

 

You can use GlideRecord directly on the client script.

 

https://docs.servicenow.com/en-US/bundle/utah-api-reference/page/app-store/dev_portal/API_reference/...

 

This will save you the hassle of using GlideAjax.

 

Kind Regards,

Swarnadeep Nandy

KM SN
Tera Expert

In my office using glide record in client script strictly considered as inefficient in using best practices. 

 

Instead of this if you provide any modifications to provided that could be helpful.  

yeah. but honestly you gain just few miliseconds(network time) and few kbs of data thats it - System wise.

but with GlideAjax you lose quite a bit of your mental strength, writing so many lines of codes extra just to retrieve a small thing from serverside.

 

Regarding the above code, you need to unwrap the answer variable in the client script to get the output which you are sending from scriptInclude.

Like how @Sandeep Rajput has mentioned below.

function showDetails(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    alert(answer);
    g_form.setValue('findings', anwer);
}

and I would recommend changing the scriptInclude return variable name from answer  to something else. As it is confusing which answer is what.

 

kind Regards,

Swarnadeep Nandy

Sandeep Rajput
Tera Patron
Tera Patron

@KM SN in your function showDetails(answer) function can you replace the first line with the following.

 

answer = answer.responseXML.documentElement.getAttribute("answer");