- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 06:07 AM
Hello all,
I have a field 'Recipients' on cmdb_ci_service table
type : list - referred to user table
my requirement is to dot-walk the field on the Outage table(cmdb_ci_outage). I was able to dot-walk the field just fine but it's not fetching the values from 'Recipients'(cmdb_ci_service).
How can this be achieved? Do i have to write a business rule for this? If yes,plz help me with the code.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-18-2018 05:32 AM
OK, I made a mistake... it happens at 6AM. 🙂
Remove the condition and use this in the script instead. Same assumptions apply.
// If cmdb_ci has a value (not null)
if (current.cmdb_ci) {
// Get the cmdb_ci record
var ci = current.cmdb_ci.getRefRecord();
// if the cmdb_ci record is a service
if (ci.getTableName == 'cmdb_ci_service') {
// Copy the recipients from the service record to the outage record
current.u_recipients = current.cmdb_ci.u_recipients;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 06:25 AM
you will need a business rule to do this. The reason is because Configuration item on cmdb_ci_outage points to cmdb_ci which does NOT contain your list field "Recipients". That exists further down in the class structure. It's just like trying to get caller_id from incident by reference task.
Your business rule will have to do a lookup of the record on cmdb_ci_service if the class is cmdb_ci_service, if not, don't run the business rule.
At a high level, this is what your BR will look like:
Name: Copy Recipients
Table: cmdb_ci_outage
When: BEFORE
Advanced: true
Insert: true
Update: true // You decide if you want this to run when the outage record is updated
Condition: current.cmdb_ci.getTableName() == 'cmdb_ci_service'
Script:
(function executeRule(current, previous /*null when async*/) {
// Copy the value from service to outage
// Modify field names as appropriate
if (current.cmdb_ci) {
current.u_recipients = current.cmdb_ci.recipients;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 07:41 AM
Thank for your reply,
I used the above business rule and its not working.
plz look at the screenshots below.
CI = Email - from cmdb_ci_service table
Business rule that i have configured
ci 'Email' selected and it's not populating the values
Kindly see if i have to make changes in Business rule
TIA

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 08:08 AM
I made some assumptions that may require you to adjust your business rule.
Assumption 1: your field on the cmdb_ci_outage table is called u_recipients. If this is incorrect, adjust line 8 in your script.
Assumption 2: The outage recipients is going to populate after you create/update the outage record
Step 1: Check to see if the business rule is being triggered. Go to System Diagnostics> Debug Business Rules and repeat the operation. At the bottom of the screen you will see output to tell you if the BR was run or not.
==> indicates the BR script was run
<== indicates the BR script was completed
=== means the BR script was not run because the condition didn't match.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2018 08:26 AM
Hi
Assumption 1: your field on the cmdb_ci_outage table is called u_recipients. If this is incorrect, adjust line 8 in your script - Yes, It's the same.
Assumption 2: The outage recipients is going to populate after you create/update the outage record - Yes, I'm creating a new outage record.
I did the debug business rule that you have mentioned, it says that it skipped the business rule as the conditions are not met
plz tell me what to do next
TIA