Why does gs.hasRole() return different results in Background Script and ACL?

PurnaChandM
Giga Contributor

Hello everyone,

I am trying to understand the behavior of gs.hasRole() in different execution contexts.

I am using the Australia release and have created a custom role with:

  • Display Name: Intake Agent
  • Internal Name: intake_agent

This role is assigned to the integration user that calls my inbound Scripted REST API.

In a Background Script, both of the following return true:

         gs.hasRole("Intake Agent") -> true
         gs.hasRole("intake_agent") -> true

However, in the ACL used for my Scripted REST API, I get different results.

        gs.hasRole("Intake Agent") -> false
        gs.hasRole("intake_agent") -> true

The same integration user is used in both tests, and I am not impersonating any user.

I would like to understand:

  • Is this expected behavior?
  • Does gs.hasRole() only work with the internal role name inside ACLs?
  • Why does the display name work in a Background Script but not in the ACL?
  • Is there any documentation explaining this behavior?

I'm looking to understand the platform behavior rather than just using the internal role name as a workaround.

Any guidance would be greatly appreciated. Thank you!

0 REPLIES 0