- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-21-2024 09:28 PM
I have a requirnmnet , on Incident Form caller should be autopopulated based on current logdin user in ServiceNow.
Can anyone help with code ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-22-2024 07:15 AM
Yes you can use g_user API in client script and gs.getUser() will work
g_form.setValue('caller_id', g_user.userID);
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï YouTube: https://www.youtube.com/@learnservicenowwithravi
ï LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-22-2024 08:17 AM
@SandeepKSingh You can create an onLoad client script on the incident form to populate logged in user on the incident form.
function onLoad() {
// Check if the form is new (to avoid changing the caller on existing incidents)
if (g_form.isNewRecord()) {
// Set the 'Caller' field to the logged-in user
g_form.setValue('caller_id', g_user.userID);
}
}
Please mark the solution helpful and accepted solution if it manages to address your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-23-2024 11:28 PM
As you requested :-
PFB full script :-
function onLoad() {
if (g_form.isNewRecord()) {
if (!g_form.getValue('caller_id')) {
g_form.setValue('caller_id', g_user.userID);
}
}
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï YouTube: https://www.youtube.com/@learnservicenowwithravi
ï LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-23-2024 11:37 PM
You can you the above in case of Service Catalog also as in Service catalog we have variables which you can access based on catalog client script and auto-populate current lodging user on the catalog form
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï YouTube: https://www.youtube.com/@learnservicenowwithravi
ï LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-23-2024 11:28 PM
As you requested :-
PFB full script :-
function onLoad() {
if (g_form.isNewRecord()) {
if (!g_form.getValue('caller_id')) {
g_form.setValue('caller_id', g_user.userID);
}
}
}
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï YouTube: https://www.youtube.com/@learnservicenowwithravi
ï LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-23-2024 11:37 PM
You can you the above in case of Service Catalog also as in Service catalog we have variables which you can access based on catalog client script and auto-populate current lodging user on the catalog form
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï YouTube: https://www.youtube.com/@learnservicenowwithravi
ï LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-24-2024 04:38 AM
@SandeepKSingh Wow, you seem to be interested in answers from only one person. Good Luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-24-2024 06:55 AM - edited â08-24-2024 06:56 AM
@Sandeep Rajput I do mark your answer as Helpful and accepted it but yestrday my Servicenow community had some issues the reason its not accepted. you can check other quesytions where ever you replied I marked as helpful.
And please don't put allegation on anyone.. apart from this forum help people like Ravi and Atul is doing on Youtube or at many places .