AniketC85155510
Kilo Patron

Hello @Utkarsha  ,

Please give a try to the modified script below and see how it works for you.

var grCompany = new GlideRecord('core_company');
grCompany.addEncodedQuery('sys_id=');
grCompany.query();

if (grCompany.next()) {
    var grInstance = new GlideRecord('asmt_assessment_instance');
    grInstance.addEncodedQuery('vdr_tiering_assessment=5b4');
    grInstance.query();

    if (grInstance.next()) {
        var responses_data2 = gs.getProperty('sn_vdr_risk_asmt.Business data tier 2').split(',');

        var grAsmt = new GlideRecord('asmt_metric_result');
        grAsmt.addEncodedQuery('metric.nameSTARTSWITHIdentify each category of Uber data that the third party will collect, receive, store or disclose:^metric_definition.sys_idIN' + responses_data2);
        grAsmt.query();

        while (grAsmt.next()) {
            // Check if the metric_definition.sys_id is in the list of responses_data2
            if (responses_data2.indexOf(grAsmt.metric_definition.sys_id.toString()) !== -1) {
                grCompany.u_business_data_tier = 'Tier 2';
                grCompany.autoSysFields(false);
                grCompany.setWorkflow(false);
                gs.info("Updated Company " + grCompany.name);
                grCompany.update();
            }
        }
    }
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks,

Aniket

View solution in original post