- 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: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-26-2020 10:26 AM
yeah i can pull up the field but can i change the name of the field. I don't want the field name to be displayed as department. I see that any variable label changes will affect the parent table. Can i know how can i achieve this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020 01:28 PM
Ahhh! I see, The field label can be overridden but that functionality only exists with the fields of the parent table. So, unfortunately department field label can not be changed.
However, when the cursor is hovered over the field it would show like below:
Also, I would not recommend to go with a default value since, once the default value is stored it will never be updated dynamically if the assigned to is changed and every time the ticket is reassigned field needs to updated manually.
A custom field with a onChange client script and Script Include, where with the help of glideajax in client script you could glide on user table in script include to pick the department field value and set the value on your field via client script.
Above, will do a job but I'm looking if something can be done without the client script and script include, i will update you if I find anything otherwise I will update you with the client script and Script include which you can use.
.
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-26-2020 01:41 PM
Found one more way for you, You can set the calculated checkbox true in the dictionary and use the below script:
(function calculatedFieldValue(current) {
// Add your code here
return current.assigned_to.department.name; // return the calculated value
})(current);
The field will be read only and can not be editable. The only thing I noticed is the field will be automatically updated when the form loads.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2020 10:37 AM
Hi Rithu,
Please follow the below code in type specification of department reference field by choosing reference type to advanced:-
javascript:sys_id='+gs.getUser().getUserByID(current.assigned_to).getDepartmentID();
If i was able to solve your query, please mark my answer correct and helpful.
Thanks & regards,
Prasant kumar sahu