How to hide a variable in MRVS for a specific catalog item only

Aditya02
Tera Guru

I want to Hide a Variable (state_name) which exists in a Multi row Variable set for a specific catalog item. I've tried set display, setvisible by writing a onload and ui policy scripts. but it wo'nt worked. Any one have any idea to hide variable in MRVS for specific cat item.. this requirement is little bit urgent.. 

Thank you in advance.

1 ACCEPTED SOLUTION

Murthy Ch
Giga Sage

@Aditya02 

You can try something like below in MRVS client script:

function onLoad() {
    //Type appropriate comment here, and begin script below
    function getParameterValue(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regexS = "[\\?&]" + name + "=([^&#]*)";
        var regex = new RegExp(regexS);
        var results = regex.exec(top.location);
        if (results == null) {
            return "";
        } else {
            return unescape(results[1]);
        }
    }

    var catSysId = getParameterValue('sys_id');
    if (catSysId == "7198552237b1300054b6a3549dbe5dea") { //replace with your cat item sys_id and variable name
        g_form.setDisplay('device_type', false);
    }
}

(=tested)

 

Thanks,
Murthy

View solution in original post

16 REPLIES 16

@Aditya02 

I believe I have also provided the correct answer.

As per new community feature you can mark multiple responses as correct.

If my response helped please mark it correct as well so that it benefits future readers.

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

@Aditya02 

Any update to my above comment?

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