Autopopulate a field on the incident form from the user table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-08-2024 12:38 PM
I've watched countless YouTube videos, read numerous Community articles and still I cant seem to populate a field from the User table on the incident form based on the caller_id. I created a dictionary entry called T-ID and made it a reference and then created various scripts including Client scripts and script includes and cant seem to get it to work. I even tried to use the user's email in case we accidentally set up the dictionary entry wrong and I cant get that to populate either (this was previously configured for us).
Trying to understand if I missed a step in the process. Any help would be appreciated! Here is a very rudimentary outline of what I did:
Step 1. Created a dictionary entry for T-ID (reference to the sys_user table)
Step 2: Added the field to the incident form
Step 3: Created a client script (tried so many versions at this point that writing them out seems unreasonable) to pull caller_id (field name for us is contact) and return the T-ID (u_t_id)
Step 4: Create a Script Includes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 06:14 AM
if u_t_id is reference then it just needs sysId
If your requirement is to auto-populate u_t_id with Contact then simply use this script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if(newValue == '')
g_form.clearValue('u_t_id');
g_form.setValue('u_t_id', newValue);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 06:24 AM
Okay this is the closest I've gotten to success! Right now it's autopopulating but it's the wrong field...
Did I incorrectly set up the dictionary entry? I checked the sys_user table to make sure the correct data was in the T-ID column and it is.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 10:35 AM
T-ID is referencing the user table, so it will display the user record.
In your user table, is T-ID a string or reference. If it is a reference to a different table, you should have the same reference table instead of user in incident table.
Otherwise I would suggest making it a string field.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 11:01 AM
Okay we are getting closer and closer but I think I need to make some additional adjustments and definitely need some explaining for understanding.
We have the T-ID in the user table as a string.
Based on your suggestion (which I dont quite follow why this wouldnt be a reference) I changed the other dictionary entry for T-ID on our incident table to a string (I tried both the string and the Full UTF-8 (is one better over the other?))
Now when you open a ticket in the UI view the correct T-ID is displayed but when changed to another caller T-ID becomes a string of characters.
This is the coding we currently have in our client script per a member of the community in this thread)
In the SOW nothing populates in the T-ID field. I didnt think there were separate dictionary entries. I thought you just had to add the field to each form.
I really appreciate your help so far!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2024 02:30 PM - edited ‎01-09-2024 02:32 PM
you client script should be
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue == ''){
g_form.clearValue('u_t_id');
}
else
{
var gr = g_form.getReference('caller_id');
var caller = g_form.getReference('caller_id', doAlert); // doAlert is our callback function
function doAlert(caller) { //reference is passed into callback as first arguments
g_form.setValue('u_t_id',caller.u_t_id);
}
}
}
Please mark this response as correct or helpful if it assisted you with your question.