I am facing below issue in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 12:21 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 06:55 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 06:57 AM
var test = 'Yes';
if ('yes' == test)
gs.info('Yes!');
else
gs.info('No!');
// Output -->> No!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 09:02 AM
Can I use same code for 20 variables.
Do I need to use null pointer for all the variables?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 11:10 PM
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2022 11:53 PM
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