In ServiceNow scripting, which object is used to check a user's roles, as shown by hasRoleExactly?

Prepare for the ServiceNow CAD Exam with comprehensive flashcards and multiple-choice questions. Each query offers hints and explanations. Ensure your success on the exam!

Multiple Choice

In ServiceNow scripting, which object is used to check a user's roles, as shown by hasRoleExactly?

Explanation:
Checking a user’s roles in server-side Script includes using the GlideUser object that represents the current user. The global g_user is that object, and it provides methods to inspect what roles the user has. The hasRoleExactly method is a function on that GlideUser instance, so you call it as g_user.hasRoleExactly('role_name') to determine if the current user possesses that specific role. This is why g_user is the right choice: it directly represents the user performing the script, and hasRoleExactly is designed to be used on this object to check role membership. Other options aren’t the correct match for this operation: gs is for general system operations, not per-user role checks; GlideUser refers to the class rather than the actual user instance; current is a record object and not related to the user's roles.

Checking a user’s roles in server-side Script includes using the GlideUser object that represents the current user. The global g_user is that object, and it provides methods to inspect what roles the user has. The hasRoleExactly method is a function on that GlideUser instance, so you call it as g_user.hasRoleExactly('role_name') to determine if the current user possesses that specific role.

This is why g_user is the right choice: it directly represents the user performing the script, and hasRoleExactly is designed to be used on this object to check role membership. Other options aren’t the correct match for this operation: gs is for general system operations, not per-user role checks; GlideUser refers to the class rather than the actual user instance; current is a record object and not related to the user's roles.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy