GlideURL question

Lucky1
Tera Guru

Hello all,

 

Good day!!.

On a catalog item, there is a select-box, and when I select Access request, it should navigate me to new access request form.

I can achieve this by creating a system property and use that in client script from script include.

But the property's value has to be changed manually in Prod instance. Hence I am thinking to use GlideURL which can be used at server side.

I am trying this, but the script include is returning null, can you please help me?

Below are the screen shots for Script include and On change CS:

 

Lucky1_0-1759044448269.jpeg

 

Lucky1_1-1759044491882.jpeg

 

 

Regards,

Lucky

 

 

 

 

3 REPLIES 3

Rafael Batistot
Kilo Patron

Hi @Lucky1 

 

in your client script replace 

 

ga.getXML(function(response) {

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

 


This usually not work, sometimes GPT or some IA give this alternative but I’ve tried and not work. 

As documentation try: 

 

ga.getXML(HelloWorldParse);

 

And the function: 

 

function HelloWorldParse(response) {  
   var answer = response.responseXML.documentElement.getAttribute("answer"); 
    alert(answer);
}


https://www.servicenow.com/docs/pt-BR/bundle/yokohama-api-reference/page/app-store/dev_portal/API_re...

 

RaghavSh
Kilo Patron

@Lucky1 If you just want to store some value ( which has to be used in client script)  and want to change that in prod, you don't need to write ajax and script include for that.

 

Go to "sys_ui_message" and create a record in that table with some key and message as value.

In your client script use getMessage('key') , where key is from sys_ui_message table. This will fetch the value dynamically from sys_ui_message table and can be changed in prod.

 

GlideAjax has to be used for more complex logics.


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023
LinkedIn

Ankur Bawiskar
Tera Patron
Tera Patron

@Lucky1 

simply store the sysId of that catalog item in property and ask admin to change in prod.

your requirement is to simply take the user to that catalog item then approach I shared will work

script it like this

Script Include

var sysId = gs.getProperty('propertyName');

return '/esc?id=sc_cat_item&sys_id=' + sysId;

Client Script: Simply redirect it using top.window.open

If my response helped please mark it correct and close the thread so that it benefits future readers.

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