The CreatorCon Call for Content is officially open! Get started here.

catalog item sys id

servicenow14710
Tera Expert

Hello developers, how to get catalog item sys id in on change client script which i need to use in script include.

I tried using : var catSysId = g_form.getParameter("sysparm_id");

but gives error
g_form.getParameter is not a function.

Any help is appreciated. Thanks!

5 REPLIES 5

Sumanth16
Kilo Patron

Hi @servicenow14710 ,

 

I have fetched sys id by below code , and passed that to script include ,



var Sysid = g_form.getUniqueValue();



Its running fine



Script Include

 

var ApplicationModule = Class.create();

 

ApplicationModule.prototype = Object.extendsObject(AbstractAjaxProcessor, {



getCatItemAppMod: function () {

 

var cat_sys_id = this.getParameter('sysparm_cat_sys_id');

 

var gr = new GlideRecord('sc_cat_item');

 

//gr.addQuery('sys_id','b69a135f13967e00be19bda12244b0e7');

 

    gr.addQuery('sys_id',cat_sys_id);

 

gr.query();

 

if (gr.next()) {

 

return "u_application=" + gr.u_application_name + "^u_module=" + gr.u_default_module;



}

 

return ' ';

 

},

 

..........



Client script



function onLoad() {

 

//Apply a default filter to the list collector variable



var ga = new GlideAjax('ApplicationModule');

 

var Sysid = g_form.getUniqueValue();

 

ga.addParam('sysparm_name','getCatItemAppMod');

 

ga.addParam('sysparm_cat_sys_id',Sysid);

 

ga.getXML(setCollectorFilter);



function setCollectorFilter(response){

 

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

 

var collectorName = 'rc_roles';

 

var filterString =catItemAppMod;

 

var myListCollector = g_list.get(collectorName);

 

              myListCollector.reset();

 

              myListCollector.setQuery(filterString);

 

} }

 

If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!

 

Thanks & Regards,

Sumanth Meda