Trying to do CAD certification how to get firstname? The following doesn't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
In the training it states that this gets the firstname: 'g_user.firstName'. However I get the following when I run the code:
"incident.System"
Any suggestions?
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @hikerclimber ,
Here are two valid reasons why g_user.firstName returns the system
1️⃣ You’re logged in as System Administrator
The default admin user has:
First name: System
Last name: Administrator
So g_user.firstName correctly returns System
Verify by checking your user record or impersonating another user (e.g., Abel Tuter)
2️⃣ The script is running in a non-interactive (server-side) context
In these cases, ServiceNow runs the code as System, regardless of who triggered it:
Business Rules (async / background)
Flow Designer actions
Scheduled Jobs
Script Includes (called server-side)
Integrations / APIs
In all these scenarios, no real user session exists, so: g_user.firstName → "System"
If this is useful, Please Mark it as helpful and Please Accept My Solution...
Best Regards,
SIVASANKARI S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Validate the User first name again in your system. Try with different user once .
e.g for System Administrator user (default one)
alert(“g_user.firstName = “ + g_user.firstName + “, \n g_user.lastName = “ + g_user.lastName + “, \n g_user.userName = “ + g_user.userName + “, \n g_user.userID = “ + g_user.userID);
Above will return

