- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 10:56 AM
Hi,
I have a field called Assigned to (assigned_to) which is referring to the User (sys_user) table on an incident form. I have a new field called department on the incident form. Based on the assigned to value, it should retrieve department and populate in the field. Can i do it through default value code on the variable. If so, what should be the expression.
Thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 12:45 PM
Hi Rithu,
You can bring the department field itself from the user table on the form, no code is needed. Please follow the below steps and you can achieve this:
1. Open the form layout of the Incident form.
2. Select the assigned to and click on the highlighted icon in the below snipped.
3. Select the department and bring it in the selected box and place is where you department field to be.
4. Save, Now the Assigned to's department field from the user table will come up on the incident form. No fields or script needs to be created.
Note- For security purpose you need to make the department field read only or else modifying the field could modify the data on user table.
Kindly mark my answer as Correct and helpful based on the Impact.
Regards,
Chaitanya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2020 12:43 PM
go to sys_user profile and check for that user hwom you select and see if he has department or not.
If its there, can you share the screenshot of the reference specification.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020 10:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020 12:35 PM
Hi Rithu,
You said the department field is on incident form, but in your screenshot the table refers to cmdb_ci. Could you cross check this once.
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020 01:18 PM
I am looking for something on cmdb_ci table itself.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020 10:41 PM
Okay.. try this. I think there is a syntax issue in the earlier line.
javascript:"sys_id="+gs.getUser().getUserByID(current.assigned_to).getDepartmentID()
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP