How can i get department value for a user in default value.

Rithu
Kilo Contributor

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.

1 ACCEPTED SOLUTION

Chaitanya Redd5
Tera Guru

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.

find_real_file.png

 

3. Select the department and bring it in the selected box and place is where you department field to be.

find_real_file.png

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

View solution in original post

14 REPLIES 14

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.

Rithu
Kilo Contributor

find_real_file.png

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

Rithu
Kilo Contributor

I am looking for something on cmdb_ci table itself.

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