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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 04:13 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2022 04:17 AM
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
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 01:58 AM
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. 😞