- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2022 11:56 PM
Hi All,
My customer wants a sync between operational status and instal staus for all the choice values present.
Ex:If operational status changed to retired then install_status should get change to retired and vice versa
If install status changes to In maintenance then operational status should also get changed to In maintenance
Please suggest some best approach to do this via script.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2022 12:02 AM
Hi,
you can use before update BR on the table
Ensure you give correct choice values for both the fields
BR Condition: current.install_status.changes() || current.operational_status.changes()
Single BR to handle both the things
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.operation_status.changes()){
// sync operational to install
var op = current.operation_status;
if(op == 'retired')
current.install_status = 'choice value';
// add else if
}
else if(current.install_status.changes()){
// sync install to operational
var install = current.install_status;
if(install == 'retired')
current.operation_status = 'choice value';
// add else if
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2022 12:02 AM
Hi,
you can use before update BR on the table
Ensure you give correct choice values for both the fields
BR Condition: current.install_status.changes() || current.operational_status.changes()
Single BR to handle both the things
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(current.operation_status.changes()){
// sync operational to install
var op = current.operation_status;
if(op == 'retired')
current.install_status = 'choice value';
// add else if
}
else if(current.install_status.changes()){
// sync install to operational
var install = current.install_status;
if(install == 'retired')
current.operation_status = 'choice value';
// add else if
}
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2023 10:42 AM
Hello Ankur ,
I have been trying to create this scenario for each run whenever i am updating the values manually BR is getting executed and running fine .
But when a CI gets updated after Discovery this BR is not executing i.e. in case i am updating the Operational status to retire manually its updating the Install status to Retire but if Discovery is running and it updates the value of Install status to retire the operational status is not in sync .
Any idea on this scenario . Do let me know
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-24-2025 07:44 AM
This was super helpful, one thing to note it's
operational_status
not operation_status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2024 08:41 AM
Hello fellow contributors! I've encountered the same situation and here is my proposed solution:
First, one would need an agreement on Install status to Operational status mapping, here is a possible one:
Cmdb_ci install status label | Value | Operational Status Match | Value | OP Status Label |
In Stock | 6 | Ready | 5 | Ready |
Installed | 1 | Operational | 1 | Operational |
Pending Repair | 5 | Repair in Progress | 3 | Repair in Progress |
Retired | 7 | Retired | 6 | Retired |
Pending Install | 4 | Non-Operational | 2 | Non-Operational |
Absent | 100 | Non-Operational | 2 | Non-Operational |
On Order | 2 | Non-Operational | 2 | Non-Operational |
Stolen | 8 | Non-Operational | 2 | Non-Operational |
In Maintenance | 3 | Non-Operational | 2 | Non-Operational |
BR: on Before, Insert + Update
Condition: current.install_status.changes()
example Script:
//and write it so on for all the mappings..