Which method call returns true only if the current logged in user has the catalog admin role and in no other case?

Prepare effectively for the ServiceNow CAD certification. Study with detailed questions and explanations. Enhance your skills and knowledge for success in your exam!

Multiple Choice

Which method call returns true only if the current logged in user has the catalog admin role and in no other case?

Explanation:
You’re testing for exact role membership. g_user.hasRole('catalog_admin') tells you whether the user has that role, but it doesn’t care what other roles they might also have. To require that the user has catalog_admin and no other roles, you use the exact variant: g_user.hasRoleExactly('catalog_admin'). This returns true only when the user’s assigned roles are precisely catalog_admin and nothing else. If the user has any additional roles, the check returns false. That’s why this is the correct form for the requirement.

You’re testing for exact role membership. g_user.hasRole('catalog_admin') tells you whether the user has that role, but it doesn’t care what other roles they might also have. To require that the user has catalog_admin and no other roles, you use the exact variant: g_user.hasRoleExactly('catalog_admin'). This returns true only when the user’s assigned roles are precisely catalog_admin and nothing else. If the user has any additional roles, the check returns false. That’s why this is the correct form for the requirement.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy