Business rule is not working

Jyothsna5
Tera Contributor

Conditions were met and business rule is executing not it's not displaying proper result, please refer below given condition

Jyothsna5_0-1766031020065.png

 

and the script is

(function executeRule(current, previous) {

    // HIGH RISK
    if (
        current.u_information_security == 'no' &&
        current.u_network_security == 'no' &&
        current.u_did_supplier_have_any_history_of_aml == 'yes' &&
        current.u_is_supplier_has_any_history_of_cyber_crime == 'yes' &&
        current.u_supplier_compliant_with_jurisdictions_rules_and_regulations== 'no'
    ) {
        current.u_inherent_risk_rating = 'high';
    }

    // MEDIUM RISK
    else if (
        (
            current.u_information_security == 'no' ||
            current.u_network_security == 'no'
        ) &&
        (
            current.u_is_supplier_has_any_history_of_cyber_crime == 'yes' ||
            current.u_did_supplier_have_any_history_of_aml == 'yes' || current.u_supplier_compliant_with_jurisdictions_rules_and_regulations== 'no'
        )
    ) {
        current.u_inherent_risk_rating = 'medium';
    }

    // LOW RISK
    else if (
        current.u_information_security == 'yes' &&
        current.u_network_security == 'yes' &&
        current.u_is_supplier_has_any_history_of_cyber_crime == 'no' &&
        current.u_did_supplier_have_any_history_of_aml == 'no' &&
        current.u_supplier_compliant_with_jurisdictions_rules_and_regulations == 'yes'
    ) {
        current.u_inherent_risk_rating = 'low';
    }

    // NOT APPLICABLE
    else {
        current.u_inherent_risk_rating = 'not_applicable';
    }

})(current, previous);

but after updating the record 'Inherent Risk Rating" field was not updating as per script, could anyone help with this issue?
Jyothsna5_1-1766031278918.png

 



3 REPLIES 3

Deepak Shaerma
Mega Sage
Mega Sage

Hi @Jyothsna5 

What exactly you need to achieve via provided business rule?? A proper requirement will help us to provide the exact solution.


PrashantLearnIT
Tera Sage

Hi @Jyothsna5 

 

Please add conditions for empty like below: 

PrashantLearnIT_0-1766038636442.png

This might solve your purpose.

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@Jyothsna5 

share dictionary config of that yes/no field

I couldn't find such field

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader