I need to be able to hide Checklist formatter based on a condition

Jerome MAISETTI
Mega Guru

Hello
I'm trying to hide the Checklist editor/formatter based on some conditions.
I created a display business rule to achieve this but it doesn't work

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var entity = current.getValue('u_service_contract.entity');
    var UK_SOC = gs.getUser().hasRoleExactly('ocd_uk_soc');
    
    if (entity == 'ocd_uk') {
        g_scratchpad.checklistVisibility = true;
    } else {
        g_scratchpad.checklistVisibility = false;
    }

})(current, previous);

Does anyone have experience with this so I can get some help ?

Thanks,

Jérôme

2 REPLIES 2

Harish KM
Kilo Patron
Kilo Patron

Hi refer the answer below. You need to pass scratchpad value to onload client script for that to work

https://community.servicenow.com/community?id=community_question&sys_id=a2bf3a6ddb58dbc01dcaf3231f96195f

Regards
Harish

I tried but it doesn't work.
So here is my business rule :

(function executeRule(current, previous /*null when async*/) {

    // Add your code here
    var entity = current.getValue('u_service_contract.entity');
    var UK_SOC = gs.getUser().hasRoleExactly('ocd_uk_soc');
    
    if (gs.getUser().hasRoleExactly('ocd_uk_soc')) {
        g_scratchpad.checklistVisibility = true;
    } else {
        g_scratchpad.checklistVisibility = false;
    }

})(current, previous);

And my client script, onLoad :

function onLoad() {
   //Type appropriate comment here, and begin script below
    if (!g_scratchpad.checklistVisibility) {
        document.getElementById('inlineChecklistApp').style.display = "none";
    } 
}

But it still shows. 😞