The CreatorCon Call for Content is officially open! Get started here.

How to make a Dictionary Entry Attribute conditional?

santrym
Mega Expert

I have a UI macro next to my configuration item field that is added using the "Attributes" field in the corresponding "Dictionary Entry" details of the configuration item. I'm wondering how I can make this macro visible only to users who have a specific role.

find_real_file.png

Here is what the current attribute is set to: 

     "ref_contributions=pcid_show_incidents;x_bmgr_support_ent_bomgar_push_start_local"

 

I'm trying to make the "x_bmgr_support_ent_bomgar_push_start_local" macro only appear for users with role "bomgar_admin".

 

Any ideas or guidance would be appreciated. Thank you!

2 REPLIES 2

sachin_namjoshi
Kilo Patron
Kilo Patron

you need to write on load client script to make macro visible to particular role.

Please check below for more details on solution

 

You can use the show_related_records out of the box UI macro as an example of how to manage the visibility of a UI macro within the macro code itself.

https://yourinstanceurl/nav_to.do?uri=sys_ui_macro.do?sys_id=2d8f82a2eb2031001c13abf11206fe83

 

Regards,

Sachin

Michael Ritchie
ServiceNow Employee
ServiceNow Employee

This needs to be accomplished in the UI Macro itself, not a client script on the form since that may require DOM manipulation which is not recommended.  At the top of your Macro you should have a <g2:evaluate> section that is evaluating when to show this Macro or not, you will need to modify that to include your role.  I don't have that macro in my demo instance so I cannot provide specific help.