- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 01:47 AM
Hello experts,
I have written a BR to update a field on particular table based on metric_definition sys ids from asmt_metric_result table
I have stored around 27 sysids by putting , in between them...now the issue is there are three different values which i have to update for the target table field...how should i modify the conditions here could anyone please suggest me?
var grCompany = new GlideRecord('core_company');
grCompany.addEncodedQuery('sys_id=');
grCompany.query();
gs.info("out-1");
if (grCompany.next()) {
gs.info("inside");
//Get the Assessment instances from the response of IRA
var grInstance = new GlideRecord('asmt_assessment_instance');
grInstance.addEncodedQuery('vdr_tiering_assessment=5b4');
grInstance.query();
gs.info("outside");
if (grInstance.next()) {
gs.info("inside");
var responses_data2 = gs.getProperty('sn_vdr_risk_asmt.Business data tier 2').split(',');
//var responses_data3 = gs.getProperty('sn_vdr_risk_asmt.Business data Tier 3').split(',');
// var responses_data1 = gs.getProperty('sn_vdr_risk_asmt.Business data Tier 1').split(',');
//Get the locations selected as a part of users response
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();
gs.info("out");
if (grAsmt.next()) {
gs.info("inside");
gs.info(responses_data2);
grCompany.u_business_data_tier = 'Tier 2';
grCompany.autoSysFields(false);
grCompany.setWorkflow(false);
gs.info(" Updated Company " + grCompany.name);
grCompany.update();
}
//} //else if (grAsmt.metric_definition ==responses_data3) {
// coreData.u_business_data_tier = 'Tier 3';
//coreData.autoSysFields(false);
//coreData.setWorkflow(false);
// gs.info(" Updated Company " + coreData.name);
//coreData.update();
// } else if (grAsmt.metric_definition == responses_data1) {
// coreData.u_business_data_tier = 'Tier 1';
//coreData.autoSysFields(false);
//coreData.setWorkflow(false);
// gs.info(" Updated Company " + coreData.name);
// coreData.update();
//}
// }
// }
}
}
I have commented the below lines which are not working
Any kind of help here is greatly appreciated
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 02:14 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2024 02:14 AM
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