How to call system property in catalog client script

Devaceis
Tera Contributor

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-

Devaceis_0-1679644623260.png

system properties-

Devaceis_1-1679644666915.png

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.

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@Devaceis 

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.

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

Script include-

Devaceis_0-1679645961213.png

Client script-

Devaceis_1-1679646025178.png

but it is not working

@Devaceis 

is that alert coming?

both client script and script include are in same scope?

Also move the IF statement within that callback method.

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

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.