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

I think its because a yes/no variable contains the value of "Yes" and "No" which are not same as "yes" and "no" so it will always evaluate to false.

var test = 'Yes';
if ('yes' == test)
  gs.info('Yes!');
else
  gs.info('No!');

// Output -->> No!

Gopal14
Tera Contributor

Can I use same code for 20 variables. 

 

Do I need to use null pointer for all the variables?

The same code, no.

The same method/syntax, yes. 😀

someGlideRecordObject.setValue('field_name', 'value_of_some_kind');

 

What do you mean by the other question, about nullpointer ?

Gopal14
Tera Contributor

I am using below

 

govrec.setValue('u_agent_health', reqitem.variables.agent_health.toString());

if (reqitem.variables.agent_health == 'Yes') {
govrec.setValue('u_agent_health', true);

} else {
govrec.setValue('u_agent_health', false);
}

 

above code is working fine,

 

I am using same code(I will change variable names) for all other 20 variables