Lessons › Domain 3: Security and Restricting Access (20%) › Lesson 11
Scripting Security with GlideSystem
About 13 minutes · Last checked against the CAD blueprint (January 2026): 4 December 2026
Step 1 · Learn
Security decisions in code
When roles and conditions are not enough, an access control or another script can check the user in code. The GlideSystem object gs and the GlideUser object it returns are the tools for this.
GlideSystem methods
| Method | Returns |
|---|---|
gs.hasRole('x_acme_loans.manager') | true if the current user has the role |
gs.getUserID() | The sys_id of the current user |
gs.getUserName() | The user name of the current user |
gs.getUser() | A GlideUser object for the current user |
gs.isInteractive() | true if the session is interactive, such as a person in the browser |
GlideUser methods
| Method | Returns |
|---|---|
getFullName() | The user's full name |
getID() | The user's sys_id |
hasRole() | true if the user has the role |
isMemberOf('Loan Desk') | true if the user is in the group |
getEmail() | The user's email address |
A typical access control script
To let users read only their own requests, the script compares the record's Requested for with the current user: answer = current.requested_for == gs.getUserID();. Combine it with a role so the check only applies to users of the application.
On the client
g_user.hasRole() is useful for showing or hiding things on a form, but it is not security: anything in the browser can be changed. Always enforce access on the server.
Step 2 · Do
Check users in scripts
Write the security checks for the loans application with GlideSystem and GlideUser. This is a practice environment of our own design, not the ServiceNow product. Complete the tasks in the task list.
Step 3 · Check
Exam-style questions
Select an answer and check it. Every answer includes an explanation.