How to link two different tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 02:41 AM
Hi All
I need to link two tables one is sys_user and one custom table based on few fields from sys_user tables.
When values in the sys_user gets updated same should be reflected in custom table.
How to achieve this, via a business rule?
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 02:46 AM
Hello Ravi Teja,
Use On after BR(update) and condition(as per your requirement).
Use the below sample script:
assume that you have written in the incident table and updating on SLA table(task_sla).
var inc = new GlideRecord('task_sla');
inc.addQuery('task',current.sys_id);
inc.addQuery('type','sla');
inc.query();
while(inc.next())
{
current.u_custom_field = inc.your_tasksla_field;
}
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 02:49 AM
Before we suggest code solutions, we should be sure we understand the data structure.
The fields that change on your custom table... would you describe them as fields that "come from" the User record? Or are they fields that belong on your custom table, but merely change with some of the User's fields?
Because one option would be to have anything User related that changes as part of the User from, then simply display those fields on your custom table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 03:27 AM
When values in the sys_user gets updated same should be reflected in custom table.
.. then why not use a Reference Field, if the two were related?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-27-2017 03:34 AM
fields in sys_user table are single line text fields. Data is coming from integration where we don't have access to use it.
we are trying to write a code to fetch unique values from a field for example division and populate those fields in the custom table.