Get sys_id of included item of an order guide - service portal

michal_v
Giga Contributor

Hey,

Does anyone know how can I tell, when I'm inside an order guide in service portal, what is the item sys_id (not the order guide sys_id)?

1 ACCEPTED SOLUTION

g_form.getUniqueValue()   will provide you with catalog item sys_id.



catItem = $("sysparm_id").value;             ----->         catItem = g_form.getUniqueValue() ;


View solution in original post

8 REPLIES 8

Gurpreet07
Mega Sage

All included items stored in an array data._items . Traverse over items and data._item[i].sys_id     will provide the sys_id of each item. You could simply log all the data to browser console simply by selecting ctrl + rc ---> log scope.data       on any widget.


Thanks for the quick replay Gurpeet, but is there a why to get the sys_id of an item when I'm in a catalog client script?


I have scripts that usesthe sys_id of the item with the hidden input of the order guide (sysparm_id, or current_item) is there a alternative for service portal?


Gurpreet07
Mega Sage

Is this script on Order Guide itself or on one of catalog items ? Can you please paste the script ?


the problem in this catalog client script is that it's running on a variable set:



function onChange(control, oldValue, newValue, isLoading) {


if (isLoading || newValue == '') {


return;


}



var catItem;



if ($("sysparm_id")) // tryin to find the current item sys_id in order to pass it to script include - work inside the system but not in the service portal


catItem = $("sysparm_id").value;



else if ($("current_item"))


catItem = $("current_item").value;




var ga = new GlideAjax('TVA_populateServiceOfferingVar');


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


ga.addParam('sysparm_ci',g_form.getValue('u_customer_ci'));


ga.addParam('sysparm_user',g_form.getValue('caller_id'));


ga.addParam('sysparm_cat_item',catItem);


ga.getXML(offerNumParse);



function offerNumParse(serverResponse) {


var res = serverResponse.responseXML.getElementsByTagName("res");


var count = res[0].getAttribute("value");


if (count < 2 ){


var offer = res[1].getAttribute("value");


g_form.setValue('service_offering',offer);


g_form.setReadOnly('service_offering',true);


g_form.setDisplay('service_offering',false);


}


else{


g_form.setDisplay('service_offering',true);


g_form.setReadOnly('service_offering',false);


g_form.setValue('service_offering',"");


}


}


}