How to call a system property on catalog client script or UI policy?

Kirthi2
Tera Contributor

I have not written this before and fairly new to this approach on calling system property on client side scripting
and trying to understand how to call a system property on a Catalog client script? 

I have defined a system property where the Value is null. when the system property value is null then I want to display certain options.

Below is the screenshot of the client script, when the system property is null and the value of the variable 'ref_req_company' is 'XYZ company' then an option needs to display.

It's not working and not displaying the option I have given under setDisplay.

find_real_file.png

Below is the business rule where I defined g_scratchpad 

find_real_file.png

I am stuck at this point and not able to move forward. any help is greatly appreciated.

1 ACCEPTED SOLUTION

You can use below Script include.

find_real_file.png

var propertyUtil = Class.create();
propertyUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getProperty: function() {
        return gs.getProperty('catalog.csa.exclude.lead_mfs');
    },
    type: 'propertyUtil'
});

Catalog client script.

function onLoad() {
    var ga = new GlideAjax('propertyUtil'); //This argument should be the exact name of the script include. 
    ga.addParam('sysparm_name', 'getProperty'); //sysparm_name is the name of the function in the script include to call. 
    ga.getXML(myCallBack); //This is our callback function, which will process the response.

    function myCallBack(response) { //the argument 'response' is automatically provided when the callback funciton is called by the system.
        //Dig out the 'answer' attribute, which is what our function returns. 
        var prop = response.responseXML.documentElement.getAttribute('answer');
        alert(prop); //alert the result to make sure all is well.
    }
}

 

Hope it helps.

View solution in original post

6 REPLIES 6

Pratima Kalamka
Kilo Sage

Hi @Pratima Kalamkar ,

Thank you for your response.

I checked the 2 links you referred to but I don't think they will work for my situation. 

Because I am trying to get a system property on the client script in catalog items and display certain items.