The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Approval is required on state change of Vulnerability Item from In review to Awating Implementation

saptarshiamc
Tera Contributor

There is a requirement - if user want to change the state of Vulnerable item (in sn_vul_vulnerable_item table) from In review to Awating Implementation, it should ask for approval from the support group of the asset. HIf any member of the support group approves it, then the Vulnerable item will move to  the Awating Implementation state and if rejected then it will move to open state. And the approval details must populate in the "Requested Approvals" related list in the vulnerable item form view. How to do that?

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

HI @saptarshiamc ,
I trust you are doing great.
To meet this requirement in ServiceNow, you will need to implement a workflow or flow designer process that triggers when the state of a vulnerable item changes from "In Review" to "Awaiting Implementation". This process will create an approval record linked to the vulnerable item and manage the state transitions based on the approval response.

You can try with the business rule also , please look into below code for reference :

(function executeRule(current, previous /*null when async*/) {

    // Check if the state is changed to 'Awaiting Implementation'
    if (current.state == 'Awaiting Implementation' && previous.state == 'In Review') {

        // Identify the support group for the asset
        var supportGroup = getSupportGroup(current.asset);

        // Create approval record
        var approval = new GlideRecord('sysapproval_approver');
        approval.initialize();
        approval.approver = supportGroup; // Assuming supportGroup contains a valid group sys_id
        approval.source_table = 'sn_vul_vulnerable_item';
        approval.source_id = current.sys_id;
        approval.state = 'requested';
        approval.insert();

        // Add additional logic to handle approval response and state transition
        // ...
    }

    // Function to get the support group of the asset
    function getSupportGroup(assetId) {
        var asset = new GlideRecord('alm_asset');
        if (asset.get(assetId)) {
            return asset.support_group;
        }
        return null;
    }

})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi