Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How do you hide the checklist formatter?

akaupisch
Kilo Guru

I have a checklist on a task that I only want to display if it's assigned to a certain group. Because formatters aren't typical items, you can't just use g_form.setDisplay...so I tried:

document.getElementById('inlineChecklistApp').style.display = "none";

...but that has no effect. Anyone know how to dynamically show/hide the checklist?

As part 2 of that question, is there a way to disable the Save / Create Template options on the formatter for end users that i don't want to add/create things?

1 ACCEPTED SOLUTION

chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hi Adam,



For checking, if the current logged in user is member of assignment group, you can use Display Business Rule :



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


  g_scratchpad.checklistVisibility = false;



  if(gs.getUser().isMemberOf(current.getDisplayValue('assignment_group')))


            g_scratchpad.checklistVisibility = true;



})(current, previous);



and in onLoad client script, you can use below script to hide checklist :



if(!g_scratchpad.checklistVisibility)


  //jQuery('#inlineChecklistApp').hide();


document.getElementById('inlineChecklistApp').style.display = "none";



View solution in original post

6 REPLIES 6

sachin_namjoshi
Kilo Patron
Kilo Patron

Hi Adam,



You can hide,show form section by using below code



https://www.servicenowguru.com/scripting/client-scripts-scripting/showhide-form-section/



But,i am not sure about checklist formatter.



Regards,


Sachin


wrapping it in a section then hiding that section technically works, but the UI looks bad...any other thoughts?


This works on my personal instance (Helsinki) - jQuery('.checklist_section.ng-scope').hide();


chirag_bagdai
ServiceNow Employee
ServiceNow Employee

Hi Adam,



For checking, if the current logged in user is member of assignment group, you can use Display Business Rule :



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


  g_scratchpad.checklistVisibility = false;



  if(gs.getUser().isMemberOf(current.getDisplayValue('assignment_group')))


            g_scratchpad.checklistVisibility = true;



})(current, previous);



and in onLoad client script, you can use below script to hide checklist :



if(!g_scratchpad.checklistVisibility)


  //jQuery('#inlineChecklistApp').hide();


document.getElementById('inlineChecklistApp').style.display = "none";