Set Highest Designation

Utkarsha
Tera Contributor

Hello All,

I would like to know if user has selected multiple values for metric in asmt_assessment_question table then, our requirement is to select highest designation which is again a new metric in the same questionnaire....currently my code is selecting highest value and setting the designation based on the value attached to the designation

Could anyone suggest where should I make changes so that when user has selected multiple values for a metric , based on the values selected it will set the highest designation

FYI, Highest designation is another metric with choices Level 1, Level 2, Level 3, Level 4

I want if values selected by user has multiple values for the first metric then based on the mapping stored in system property for designation metric --- field should be updated by highest level only ---lets say has mapping for 2,3,1 then only 1 should be selected 

I am using below code-

All suggestions are welcome here

Thank you!

setDesignation: function(current)  {
 
var grCompany = new GlideRecord('core_company');
grCompany.addEncodedQuery('sys_id=' + current.vendor );
grCompany.query();

if (grCompany.next()) {


//Get the Assessment instances from the response of IRA
var grInstance = new GlideRecord('asmt_assessment_instance');
grInstance.addEncodedQuery('vdr_tiering_assessment=' + current.sys_id);
grInstance.query();


if (grInstance.next()) {

//Fetching & comparing values of asmt metric definitions for the metric Identify each category

var responses_data2 = gs.getProperty('sn_vdr_risk_asmt.category_tier2').split(',');
var responses_data3 = gs.getProperty('sn_vdr_risk_asmt.category_tier3').split(',');
var responses_data1 = gs.getProperty('sn_vdr_risk_asmt.category_tier1').split(',');
var responses_data4 = gs.getProperty('sn_vdr_risk_asmt.category_tier4').split(',');

//Get the responses selected as a part of users response
var grAsmt = new GlideRecord('asmt_assessment_instance_question');
grAsmt.addEncodedQuery('metric.nameSTARTSWITHIdentify each category :^instance=' + grInstance.sys_id);
grAsmt.query();

while (grAsmt.next()) {
if (responses_data2.toString().includes(grAsmt.metric_definition.value.toString())) {
 
grCompany.u_designation = 'Tier 2';
 

} else if (responses_data3.toString().includes(grAsmt.metric_definition.value.toString())) {
 
grCompany.u_designation = 'Tier 3';
 

} else if (responses_data1.toString().includes(grAsmt.metric_definition.value.toString())) {
 
grCompany.u_designation = 'Tier 1';
 

} else if (responses_data4.toString().includes(grAsmt.metric_definition.value.toString())) {
 
grCompany.u_designation = 'Tier 4';
 


}


grCompany.update();

}
}
}
},
0 REPLIES 0