Is it possible to hide a variable like "Address" from a catalog item

B Ashok
Tera Guru

Is it possible to hide a variable like "Address" from a catalog item in ServiceNow once the request is fulfilled. Untill the RITM Is fulfilled variable should be visible, once it's fulfilled variable value or variable with value should be hide. 

Example : 
Catalogue ITEM  : ABC

                  Variable : Address
I tried with Catalouge UI policy and UI Policy both not supporting. I tried with below Script inlcude and catalogue client script not working please help me on this. 

 

Catalogue Client script : 

function onLoad() {
    var ritmID = g_form.getParameter('sysparm_id');
    if (ritmID) {
        var ga = new GlideAjax('RITMStateCheck');
        ga.addParam('sysparm_name', 'getRITMState');
        ga.addParam('sysparm_ritm_id', ritmID);
        ga.getXMLAnswer(function(answer) {
            if (answer == '6') { // 6 = Fulfilled
                g_form.setDisplay('address_1', false); // 'address_1' is the variable name 
            }
        });
    }
}

Script include : 

// Name: RITMStateCheck
// Accessible from: Client Callable
var RITMStateCheck = Class.create();
RITMStateCheck.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getRITMState: function() {
        var ritmID = this.getParameter('sysparm_ritm_id');
        var gr = new GlideRecord('sc_req_item');
        if (gr.get(ritmID)) {
            return gr.state.toString(); // Returns state as string (6 for Fulfilled)
        }
        return '';
    }
});
5 REPLIES 5

@B Ashok 

Hope you are doing good.

Did my reply answer your question?

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