- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 09:38 AM
Hi all,
I tried auto populating the 'cost center' field value from users table, using the getReference method in business rule for incident form, but it didn't worked at all.
Please help me in retrieving the value of the cost center field value in the incident form
Solved! Go to Solution.
- Labels:
-
Incident Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 10:28 AM
Hi Naresh,
As suggested by Ankur above won't work in business rule as g_form.getReference() are client specific side options to be used.
Try using below business rule that runs After Insert on required table & make sure you have correct field name passed.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
current.location = current.caller_id.location;
current.cost_center = current.caller_id.cost_center;
current.state = current.caller_id.state;
current.city = current.caller_id.city;
current.country = current.caller_id.country;
current.update();
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 10:55 AM
I agree with
It's best practice to navigate users to the pop-up for the Caller reference field to view these fields, but if necessary to show them on the incident form the above method can be used.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 11:01 AM
Thanks for the confirmation.
Also, can you confirm if state, location,street, cost-center exists on table on which Business rule is written. If so, from your statement I see you are having Business Rule on incident table which I doubt have street, locatin, state, etc. unless custom created.
If custon created is should be
current.u_state=current.caller_id.state; & so on
Else, you can try below.
This will get in value for required fields you want from User table without having Client Scripts or Business Rule to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:03 PM
Thank you for the response.
The BR code is working for every caller except for abraham lincoln -- only country field value is not populating.
Thanks & Regards
Naresh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:09 PM
If you choose to script this solution, please make sure you're not using current.update() in an After Business Rule.
Per ServiceNow:
Do not use current.update() in a Business Rule script. The update() method triggers Business Rules to run on the same table for insert and update operations, potentially leading to a Business Rule calling itself over and over. Changes made in before Business Rules are automatically saved when all before Business Rules are complete, and after Business Rules are best used for updating related, not current, objects. When a recursive Business Rule is detected, ServiceNow stops it and logs the error in the system log. However, this behavior may cause system performance issues and is never necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2020 12:11 PM
Thank you for the reponse.
The BR code is working fine for every caller except for the ABRAHAM LINCOLN --- i.e country field value is not populating on the incident form.
May I know why?
Thanks & Regards
Naresh Uppu