- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2023 06:39 PM
Hi Team
pls advice , how to auto populate caller id details in caller filed, while loading the incident form..
i am using, client script but it is not working
find the attached images
Regards
khasim
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:39 AM
Hello @khasim523169 ,
You can the below code in you onLoad client script:
function onLoad() {
g_form.setValue('caller_id', g_user.userID);
}
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:50 AM
Hello @khasim523169 ,
Use the onload Client Script:
function onLoad() {
// Check if the record is new - Don't modify existing record
if(g_form.isNewRecord()){
g_form.setValue('caller_id', g_user.userID);
}
}
If this solves your query mark this as correct and helpful.
Thanks
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:27 AM
Try this:
function onLoad() {
// Get the current user's sys_id and name
var userId = g_user.userID;
var userName = g_user.userName;
// Set the value of the caller field on the Incident form
g_form.setValue('caller_id', userId, userName);
}
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:33 AM
Your script would almost work if there was a field named g_user on the form that was populated. If you are attempting to retrieve the current user and populate it in the Caller field, try this:
function onLoad() {
var c = g_user.userID;
g_form.setValue('caller_id', c);
}
or simply
function onLoad() {
g_form.setValue('caller_id', g_user.userID);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:39 AM
Hello @khasim523169 ,
You can the below code in you onLoad client script:
function onLoad() {
g_form.setValue('caller_id', g_user.userID);
}
If the above solution resolve your issue, Please mark the solution as 'Accepted Solution' and also mark it as 'Helpful'.
Thank You!
Prathamesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2023 04:50 AM
Hello @khasim523169 ,
Use the onload Client Script:
function onLoad() {
// Check if the record is new - Don't modify existing record
if(g_form.isNewRecord()){
g_form.setValue('caller_id', g_user.userID);
}
}
If this solves your query mark this as correct and helpful.
Thanks
Anand