Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

User Fields are not auto populating while creating catalog form

aravind1patil1
Giga Contributor

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

1 ACCEPTED SOLUTION

VaishnaviK3009
Kilo Sage

Hi @aravind1patil1 ,

  1. Create a variable:
    • Requested For (Reference → sys_user)
  2. Create variables for:
    • Department
    • Position Title
    • Email
  3. In each variable, use Autopopluate with dot-walking:
    • Departmentrequested_for.department
    • Position Titlerequested_for.title
    • Emailrequested_for.email

Screenshot 2026-04-09 100022.png

 

Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.

Regards,
Vaishnavi
Technical Consultant

View solution in original post

7 REPLIES 7

AhsanM
Tera Expert

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.

Ahsan
ServiceNow Developer & Admin
Builder of NowFixer | Free AI debugging tool for ServiceNow scripts

Thanks for your reply. I tried with Auto Populate option, it worked. Thanks once again for your time

Thanks for your reply. I tried with Auto Poulate option, it worked. Thanks once again for your time