How to call system property in catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 12:59 AM
how to call a system property on a Catalog client script?
I have defined a system property where the Value is one catalog item (AB). And for this catalog in state field On Hold option is there.
Now Requirement if in future someone add other catalog item sys_id in system property so for that item also state field option on hold should be add.
Client script-
system properties-
if someone add other item sys_id in value so for that catelog item on hold option should come in (sc_task) state field.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 01:05 AM
you should use GlideAjax and then get the system property value using gs.getProperty('propertyName') and then return that sysId and then compare
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 01:20 AM
Script include-
Client script-
but it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 01:30 AM
is that alert coming?
both client script and script include are in same scope?
Also move the IF statement within that callback method.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2023 01:38 AM
yes , alert is coming , whatever I am passing the sys_id in system property , alert is coming.
both client script and script include - yes, It should not be?
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('PropertyUtilization');
ga.addParam('sysparm_name', 'getProperty');
ga.getXML(myCallBack);
function myCallBack(response) {
if (g_form.getValue('sc_task.request_item.cat_item') == 'f046a80c1b29c910bc97dce0b24bcbf9') {
g_form.addOption('state', '5', 'On Hold', '2');
}
var prop = response.responseXML.documentElement.getAttribute('answer');
alert(prop);
}
okay
not working.