g_user.hasRole('client_script_admin');
The example script checks to see if the currently logged in user has the capability to create and edit Client Scripts (client_script_admin role). Note that the script returns true not only when the currently logged in user has the role assigned but also if the currently logged in user has the admin role. The admin user has all roles implicitly assigned. To test whether the currently logged in user has the role explicitly assigned, use the hasRoleExactly() method:
g_user.hasRoleExactly('client_script_admin');
B (https://developer.servicenow.com/dev.do#!/learn/courses/washingtondc/app_store_learnv2_scripting_washingtondc_scripting_in_servicenow/app_store_learnv2_scripting_washingtondc_client_side_scripting/app_store_learnv2_scripting_washingtondc_the_glideuser_g_user_class)
The g_user.hasRoleExactly() method in ServiceNow is used to check if the currently logged-in user has a specified role and no other roles. In this case, it checks if the user has the 'catalog_admin' role and no other roles.
So, the correct method call to return true only if the currently logged-in user has the 'catalog_admin' role and in no other case is g_user.hasRoleExactly('catalog_admin')
Correct answer is B, g_user.hasRoleExactly()
Please find this g_user.hasRoleOnly() client side script that you speak of in the below ServiceNow documentation. I can wait. :D
Source: https://developer.servicenow.com/dev.do#!/reference/api/utah/client/c_GlideUserAPI
Can you guys update the correct answer? So far I've seen the "correct answer" be incorrect a little too many times and I'm not even a quarter of the way through these questions....the correct answer is B!!!
This section is not available anymore. Please use the main Exam Page.CAD Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
kundgir
Highly Voted 3 years, 9 months agonsmcan
Highly Voted 3 years, 8 months agoesllin
Most Recent 3 weeks, 5 days agoarango
1 month, 4 weeks agoNisha2706
10 months, 2 weeks agochuks100
1 year agoKlahr
1 year agomanikanta_gnbv
1 year, 3 months agoevoken
1 year, 5 months agoBugPanda
1 year, 7 months agobrutaltea
1 year, 8 months agoLord_Korvus
1 year, 9 months agoMru9
1 year, 10 months agoAnu_K
1 year, 10 months agostophs
2 years, 1 month agoKAAAAARIM
2 years, 6 months agog_user
2 years, 7 months ago