User Fields are not auto populating while creating catalog form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Dear ServiceNow Community friends, please help if you can
I had below issue, if you can check and provide the solution. It is really great help & appreciate your response
I am creating a catalog form & below is the requirement
While filling the catalog item form, these fields should be auto populate from the user table
1. Department
2. Position Title
3. Email
Where as it reflects: Department ID, with its 'sys_id', but not with its value. I have attached the screenshot (Issue.jpeg) for your reference, please check. Position Title & Email id is not reflecting too
I have also used client script. Attached two screenshots, (Script1.jpeg & Script2.jpeg) please check. Seems there is some conflict with these two scripts. When I activate each one separately, its sys_id is reflecting, when activated both its not working at all.
Your help is highly appreciated
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
do you want to set the values with logged in user?
if yes then directly add this in default value of those variables
Department variable
javascript: var dept;
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", gs.getUserID());
gr.query();
if (gr.next()) {
dept = gr.department.getDisplayValue();
}
dept;
Do something similar for other variables
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @aravind1patil1,
Step 1: Create a script include, and it must be client-callable.
Step-2: Create an on-change client script.
If it is helpful, please mark it as helpful and accept the correct solution by referring to this solution in the future, it will be helpful to them.
Thanks & Regards,
Abbas Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @aravind1patil1 ,
- Create a variable:
- Requested For (Reference →
sys_user)
- Requested For (Reference →
- Create variables for:
- Department
- Position Title
- In each variable, use Autopopluate with dot-walking:
- Department →
requested_for.department - Position Title →
requested_for.title - Email →
requested_for.email
- Department →
Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.
Regards,
Vaishnavi
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
37m ago
Looking at your screenshots I can see exactly what is happening. You have two issues here.
Issue 1: Department showing sys_id instead of display value
On line 34 of Script 2 you are setting the department field like this:
g_form.setValue('department', res.department);The res.department value coming back from getReference() is the raw sys_id of the department record, not its display value. For reference fields you need to pass both the sys_id and the display value:
g_form.setValue('department', res.department, res.getDisplayValue('department'));This tells ServiceNow to store the sys_id but display the human readable name.
Issue 2: Position title and email not populating
Looking at your Script Include response object, check that the getDetails function on the server side is actually returning position_title and email fields. These fields may have different internal names in your instance. Common ones to check:
- Position title could be u_position_title or title depending on your instance
- Email is typically email on sys_user
Add a gs.info in your Script Include to log what res is actually returning so you can confirm the exact field names.
Issue 3: Conflict between the two scripts
Both scripts are running on the same catalog item and both are trying to populate the same fields, which causes them to overwrite each other. You should consolidate the logic into a single onLoad client script rather than having two separate scripts doing similar things. Activate only one at a time confirms this is the conflict.
The fix is to merge both scripts into one and remove the duplicate.
These kinds of issues where fields are not populating as expected or scripts are conflicting are exactly what NowFixer (nowfixer.dev) is built to help with. It is a free debugging tool for ServiceNow scripts that can help you test and validate your client script logic before deploying. Might be worth a try to save some troubleshooting time.
ServiceNow Developer & Admin
Builder of NowFixer | Free AI debugging tool for ServiceNow scripts
