UI Action button issue

vidhya_mouli
Giga Sage

I am overriding canReopen() function on IncidentUtils.

 

When I write the following code, UI Action button is visible in the Employee portal.

 

 

    canReopenIncident: function(current) {
		return current.incident_state == IncidentState.RESOLVED && gs.getUser().hasRoles() && !this._isMajorIncident(current);
    },

 

 

1.png

 

 

 

Whereas, when I write the following code, UI action button disappears in the Employee center.

 

 

            canReopenIncident: function(current) {
		return current.incident_state == IncidentState.RESOLVED && gs.getUser().hasRoles("snc_internal,itil") && !this._isMajorIncident(current);
    },

 

 

2.png

 

The user does have itil role. Also, if canReopen() return false value, it should only remove the reopen button and not the entire action button.

 

What is the problem here?

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @vidhya_mouli ,

 

Use  gs.hasRole('itil') instead gs.getUser().hasRoles()

 

FYI --gs.getUser().hasRoles() -Returns true if the user has any roles at all, false if the user has no role.

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

1 REPLY 1

Hemanth M1
Giga Sage
Giga Sage

Hi @vidhya_mouli ,

 

Use  gs.hasRole('itil') instead gs.getUser().hasRoles()

 

FYI --gs.getUser().hasRoles() -Returns true if the user has any roles at all, false if the user has no role.

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025