- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 12:43 AM
How to populate the current logged in user to caller field if no value present.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 02:06 AM
Hello,
the initialization of the default value for the caller field auto populate the caller field when a new incident is inserted.
I assume that your use case is when an existing incident is existing and for an unknow reason, the caller field is empty ... That shouldn't happen if you set the caller field mandatory ...
To give you the technical answer, please find below the client script code :
function onLoad() {
var userID = g_user.userID;
if (g_form.getValue('caller_id') == '')
g_form.setValue('caller_id', userID);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 12:55 AM
Hi Chaitanya,
At the dictionary level have the default value as javascript: gs.getUserID() for that field.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 12:56 AM
Thanks bro
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 01:33 AM
My qution is : populate the current logged in user to caller field if no value present
and iam tryed this code in client script onLoad() but its not executed
var a=g_form.getValue('caller_id');
if(a == null)
{
var b=g_user.userID;
g_form.setValue('caller_id',b);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2018 01:38 AM
Try below code:
alert(g_user.userID;);
var a=g_form.getValue('caller_id');
if(a =='')
{
g_form.setValue('caller_id',g_user.userID;);
}