I am facing below issue in flow designer

Gopal14
Tera Contributor

Hi Team,

 

I am facing below error

 

Error: Cannot set property "u_agent_health" of undefined to "undefined",Detail: Cannot set property "u_agent_health" of undefined to "undefined"

 

(function execute(inputs, outputs) {

//query the ritm with inputs.ritm_sysid, then use that record for the variables.
var reqitem = new GlideRecord('sc_req_item');
reqitem.addQuery('sys_id',inputs.ritm_sysid);
reqitem.query();
if(reqitem.next())
{

//check if there are any other governance records for this app yet:
var govrec = new GlideRecord('u_app_governance');
govrec.addQuery('u_cmdb_applications_services_name',inputs.app.sys_id);
govrec.query();
if (govrec.next()){
//update it with all the variables
gs.info('GOVACTION: I have found the gov record');
govrec.u_agent_health = reqitem.variables.agent_health;
govrec.u_alerting_for_powerful_function_to_secops_enabled = reqitem.variables.alerting_for_powerful_function_to_secops_enabled;
govrec.u_branch_runbook_s_created_in_servicenow = reqitem.variables.branch_runbook_created_in_servicenow;
govrec.u_branch_support_trained = reqitem.variables.branch_support_trained;
govrec.update();
}


} else {
govrec.u_agent_health = reqitem.variables.agent_health;
govrec.u_alerting_for_powerful_function_to_secops_enabled = reqitem.variables.alerting_for_powerful_function_to_secops_enabled;
govrec.u_branch_runbook_s_created_in_servicenow = reqitem.variables.branch_runbook_created_in_servicenow;
govrec.u_branch_support_trained = reqitem.variables.branch_support_trained;
govrec.insert();

}

})(inputs, outputs);

10 REPLIES 10

You should be able to use the same method, but you should refine your code,

try something like the following, and continue in the same pattern.

// first variable
var tempVariable = reqitem.variables.agent_health.toString();
if (tempVariable == 'Yes'){
  govrec.setValue('u_agent_health', true);
}
else {
  govrec.setValue('u_agent_health', false);
}

// second variable
tempVariable = reqitem.variables.alerting_for_powerful_function_to_secops_enabled.toString();
if (tempVariable == 'Yes'){
  govrec.setValue('u_alerting_for_powerful_function_to_secops_enabled', true);
}
else {
  govrec.setValue('u_alerting_for_powerful_function_to_secops_enabled', false);
}

// .. and continue to do the same for all yes/no variables that applies