Sync two fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 06:18 AM
Hey everyone, I'm looking into writing a BR to keep the vales of two fields in sync: Operational status and Install Status, they are both on the cmdb_ci table. I'm having a hard time trying to figure out what the best way to do this is. Screenshots below:
For example if Operational Status changes to Non-Operational then Install Status is absent.
This can't be done using the actions tab, any suggesstions or tips?
Thanks in advance,
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 06:22 AM
My first thought is to make this "data driven" as possible. Don't code more than you have to and plan for the future!!!
Create a table that maps the operational status to the install status.
Write a business rule that does a lookup on operational status and sets the appropriate install status.
Now, in the future, when someone changes your options on either list or wants to change the rules, you simply update the date in the table. No coding necessary because all the BR does it a simple lookup.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 06:46 AM
Thanks Chuck!
Would you mind giving me a quick example of what this would look like? Do I create field maps for OP status and Install Status? If I create a BR what would the conditions be?
Thanks again!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 07:18 AM
Create a simple table (not extended from anything) with two choice fields. Call them the same names as the cmdb_ci fields for simplicity.
In the dictionary for each to get the choices for your new fields from the actual values on the cmdb_ci fields (that way you don't have to replicate the choices and keep them in sync.) See this post and start the video about 7:24.
Populate the new table with your mappings of Operational status -> Install status
Create a business rule something like this... (note this is untested)
Name: Update Install Status
Table: cmdb_ci
Update: true
Insert: true
When: Before
Advanced: true
Condition (the none coding one that uses the condition builder): Operational status | changes
Script:
(function executeRule(current, previous /*null when async*/) {
// Lookup the record with the operational status matching the current record
var st = new GlideRecord('YOUR_NEW_TABLE_HERE');
if (st.get('operational_status', current.operational_status)) {
current.install_status = st.install_status;
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2018 06:26 AM
Please go through below link:
Thanks,
Abhishek Gardade
Abhishek Gardade