- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 04:02 PM
Hi,
i have a requirement if catalog is company i should hide the button oreder now in catalog item, i create a client script onload and in the client script i have :
function onLoad() {
g_form.setValue('no_order_now', true);
} // it work for me the button is hiding but is hidding in all catalog i should hide the button olnly if the name of catalog of this catalog item is comapnay :
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 06:39 PM
Try adding an alert() to check g_form.getUniqueValue() is returning a value.
function onLoad() {
try {
var catSysID = g_form.getUniqueValue();
alert(catSysID);
var ajax = new GlideAjax('ServiceCatalog');
ajax.addParam('sysparm_name', 'getServiceCatalog');
ajax.addParam('sysparm_cat_sys_id', catSysID);
ajax.getXMLAnswer(function(answer) {
if (answer.length > 0) {
if (answer == 'comapny') { // mispelling of 'company' intended?
g_for.setValue('no_order_now',true);
}
}
});
} catch (e) {
alert(e.message);
}
}
If the alert is showing a value, check Script Include's "Client callable" is checked and the name of the Script Include is "ServiceCatalog". If changing the name, ServiceCatalog in Client Script's GlideAjax('ServiceCatalog') also needs to be changed to the new name.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-14-2022 06:39 PM
Try adding an alert() to check g_form.getUniqueValue() is returning a value.
function onLoad() {
try {
var catSysID = g_form.getUniqueValue();
alert(catSysID);
var ajax = new GlideAjax('ServiceCatalog');
ajax.addParam('sysparm_name', 'getServiceCatalog');
ajax.addParam('sysparm_cat_sys_id', catSysID);
ajax.getXMLAnswer(function(answer) {
if (answer.length > 0) {
if (answer == 'comapny') { // mispelling of 'company' intended?
g_for.setValue('no_order_now',true);
}
}
});
} catch (e) {
alert(e.message);
}
}
If the alert is showing a value, check Script Include's "Client callable" is checked and the name of the Script Include is "ServiceCatalog". If changing the name, ServiceCatalog in Client Script's GlideAjax('ServiceCatalog') also needs to be changed to the new name.