Change Behaviour when Updating Install Status and Operational Status on Business Applications

nameisnani
Mega Sage

Hi Team ,

 

I have identified some incorrect behaviour when updating the statuses of Business Applications today.

When the Install status is updated to Retired, then it automatically changes the Operational Status to Retired.

When the Operational Status is changed to Decommissioned, then it automatically changes the Install Status to In Production.

This behaviour needs to be changed so that these 2 fields can be updated independently without impacting the other.

For example, if I change the value in the Install Status field, then it should have no impact on the Operational Status value.

Similarly, if I change the value in the Operational Status field, then it should have no impact on the Install Status value.

 

nameisnani_0-1752218277173.png

 

 

I am thinking is that because of this BR 

nameisnani_1-1752218326206.png

 

 

@Ankur Bawiskar  - Can you please - help me on this request . 

 

If the issue with the BR -  could you please me on the updation 

var OpsStatusSynchronizer = Class.create();
OpsStatusSynchronizer.prototype = {
    initialize: function(currentCIRecord) {
        if (!currentCIRecord)
            return;

        this.current = currentCIRecord;
        if (currentCIRecord.getElement('hardware_status')) {
            this.statusField = 'hardware_status';
            this.baseTable = 'cmdb_ci_hardware';
        } else {
            this.statusField = 'install_status';
            this.baseTable = 'cmdb_ci';
        }
    },

    shouldSync: function() {
        if (!this.current)
            return false;

        var current = this.current;
        var opsChoice = current.getElement('operational_status').getChoiceValueLang('en');
        var statusChoice = current.getElement(this.statusField).getChoiceValueLang('en');

        var retired = gs.getMessageLang('Retired', 'en');
        return opsChoice == retired && statusChoice != retired ||
            opsChoice != retired && statusChoice == retired;
    },

    syncStatus: function() {
        if (!this.current)
            return;

        var current = this.current;
        var statusField = this.statusField;
        var baseTable = this.baseTable;

        var retired = gs.getMessageLang('Retired', 'en');
        var fromOps = {};
        fromOps[retired] = retired;

        var toOps = {};
        toOps[retired] = retired;

        var ops = current.getElement('operational_status');
        var status = current.getElement(statusField);
        if (ops.changes()) { // higher priority for checking Operational Status
            var opsChoice = ops.getChoiceValueLang('en');
            var statusChoice = fromOps[opsChoice];
            var subStatusChoice = ''; // necessary to set Hardware Asset retired
            if (!statusChoice) {
                statusChoice = gs.getMessageLang('Installed', 'en');
                subStatusChoice = gs.getMessageLang('In Use', 'en');
            }
            current.setValue(statusField,
                new SNC.CMDBUtil().getChoiceListByLanguage(baseTable, statusField, 'en').getValueOf(statusChoice));
            if (baseTable == 'cmdb_ci_hardware') {
                var subStatusField = 'hardware_substatus';
                current.setValue(subStatusField, !subStatusChoice ? '' :
                    new SNC.CMDBUtil().getChoiceListByLanguage(baseTable, subStatusField, 'en').getValueOf(subStatusChoice));
            }

        } else {
            statusChoice = status.getChoiceValueLang('en');
            opsChoice = toOps[statusChoice];
            if (!opsChoice)
                opsChoice = gs.getMessageLang('Non-Operational', 'en');
            current.setValue('operational_status',
                new SNC.CMDBUtil().getChoiceListByLanguage(baseTable, 'operational_status', 'en').getValueOf(opsChoice));

        }
    },

    type: 'OpsStatusSynchronizer'
};

var synchronizer = new OpsStatusSynchronizer(current);
if (synchronizer.shouldSync())
    synchronizer.syncStatus();

 

8 REPLIES 8

Zack Hilacan1
Mega Sage

Hi there @nameisnani ,

 

Upon checking on my PDI it seems that this is inactive, this BR might just use the purpose of syncing this two fields together but I'm not sure yet, as for confimration you can either check your pdi and here's a screenshot that it is inactive : 

ZackHilacan1_0-1752219006212.png

 

If this has somehow helps, kindly give kudos or accept as solution to help others with the same concerns.

 

Thanks 😁

 

nameisnani
Mega Sage

@Ankur Bawiskar Please help me here 

 

@Zack Hilacan1  Yes In my PDI it is inactive . 

If I inactivted in cilent instance we don't what issue will come in future 

Hey,

 

So there is a similar thread and it seems to support for the legacy hardware_status sync that is not existent on the table on the new versions.

 

refer to this thread, the solver also included the reference on how it was used.

Playbook (Optional) Data Synchronization 

Do I need "Sync Ops Status for CMDB CI" Business Rule? 

 

hope this helps

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @nameisnani 

This has always been a bit of a recurring issue. On the backend, there are three tables that work together to sync the three statuses. I’m speaking from the CI side—it might not be fully applicable on your end, but it’s worth checking to understand what’s happening behind the scenes.

 

This link might not be 100% relevant but have a look

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0717902

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************