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.

Setting role on Widget Instance does not affect the visibility

Svetozar2022
Tera Expert

Widget name: Icon Link

Widget Roles (sp_widget.roles): snc_internal, snc_external

Widget Instance Roles (sp_instance.roles): custom_role1, custom_role2

 

There are 4 widget instances that are on the index page of the portal. I need one of them (widget instance with roles above) to not be shown unless these custom roles are on the user viewing it.

Constraint: Widget's server code to set data.show or similar and use it in ng-if in the HTML should not be used.

 

However, all widget instances will be are seen on the portal page even by a user without any roles. I am trying to find out why and this seems so basic and baseline from ServiceNow not to work. 

 

Does anybody know the order of importance for these roles fields?

3 REPLIES 3

boteeuwen
Tera Expert

Role Resolution Order (most specific to least specific):

  • Widget Instance Roles (sp_instance.roles) - Most specific
  • Widget Roles (sp_widget.roles) - Less specific
  • Page Roles (sp_page.roles) - Least specific

In your case, the issue is likely happening because:

  • The Widget has snc_internal, snc_external roles (basic portal access)
  • The Instance has custom_role1, custom_role2
  • When a widget instance has roles specified, it should theoretically only show to users with those roles

Troubleshooting Steps:

  1. Verify the custom roles exist and are properly assigned
  2. Check if there's a portal property overriding role checks
  3. Verify the role names are exact matches (case sensitive)

Thank you, this did help and is factual.

I have found the root cause, basically someone implemented two rows of exactly the same widgets and when looking at the page tree for widget instances I was updating the wrong row which was invisible (depends on some roles the user has). Because of this there were more than 4 widgets, 8 to be exact.

Good catch on tracking down the root cause. These kinds of role-based visibility issues can be super tricky to spot, especially when you've got duplicate widgets involved😅.