nerdexam
ServiceNow

CAD · Question #205

Which method call returns true only if the currently logged in user has the catalog_admin role and in no other case?

The correct answer is B. g_user.hasRoleExactly(`catalog_admin'). The method call that returns true only if the currently logged in user has the catalog_admin role and in no other case is g_user.hasRoleExactly(`catalog_admin'). This method checks if the user has exactly one role, and returns true if it matches the argument. The other methods re

Submitted by asante_acc· Apr 18, 2026Security and Restricting Access

Question

Which method call returns true only if the currently logged in user has the catalog_admin role and in no other case?

Options

  • Ag_user.hasRole(`catalog_admin')
  • Bg_user.hasRoleExactly(`catalog_admin')
  • Cg_user.hasRoleOnly(`catalog_admin')
  • Dg_user.hasRoleFromList(`catalog_admin')

How the community answered

(29 responses)
  • A
    3% (1)
  • B
    93% (27)
  • C
    3% (1)

Explanation

The method call that returns true only if the currently logged in user has the catalog_admin role and in no other case is g_user.hasRoleExactly(`catalog_admin'). This method checks if the user has exactly one role, and returns true if it matches the argument. The other methods return true if the user has one or more roles, or if the user has any role from a list of arguments.

Topics

#Client Scripting#g_user API#Role-based Access#Access Control

Community Discussion

No community discussion yet for this question.

Full CAD Practice