Digital product release workspace policies(record reference)

vidhisharma
Tera Contributor

Hi All,

 

Have anyone used policies with the option record reference. I m trying to figure it out but not getting much info on this. my requirement is if all the stories deployment stage is test then the policy result should get complaint. so i have created the record reference but still it is not working.. what all options i can use in the policy for this logic.

Note: Deployment stage is the custom field in story table

3 REPLIES 3

Naveen20
ServiceNow Employee

You can create a data collector similar to the one used in the existing policy - all_phase_tasks_are_complete 

The script can be modified as needed. Policy can be duplicated and edited.

vidhisharma
Tera Contributor

I have used another "all_planned_stories_complated" there i have done changes in the code ..but that is also not working

(function(inputs, outputs) {
    var releaseVersion = inputs.release_version;
    outputs.no_stories_found = true;
    outputs.sbx_percentage = 0;

    if (!releaseVersion) {
        return;
    }

    var storiesList = new sn_dpr.ReleaseCommonAccessUtil().getStoriesOfaVersion(releaseVersion);

    if (!storiesList || storiesList.length === 0) {
        return;
    }

    outputs.no_stories_found = false;

    var totalCount = 0;
    var sbxCount = 0;

    var gr = new GlideRecord('sn_devops_work_item');
    gr.addQuery('sys_id', 'IN', storiesList);
    gr.query();

    while (gr.next()) {
        var stage = gr.getValue('u_deployment_stage'); // replace with your actual field
        totalCount++;

        if (stage == 'sbx') {
            sbxCount++;
        }
    }

    if (totalCount > 0) {
        outputs.sbx_percentage = (sbxCount / totalCount) * 100;
    }
})(inputs, outputs);
 
 

Naveen20
ServiceNow Employee

Is the issue in policy mapping or execution. During test what are the outputs.