JSON/Payload parsing fails when values are updated to NULL

Patrick Slatter
Tera Guru

Morning!

I am looking for assistance in an issue around mapping NULL values. 

I have a flow action that is parsing a payload, it looks at the pay load and extracts data. There is then a simple update in the flow that is updating fields on a record based on those extracted values (logged to flow variables). It is working as expected unless that value is NULL. So if the value is updated to nothing, then we want to to remove the value on its destination record. 

How can this be accomplished in the logic? 

Error in the flow when NULL value 

PatrickSlatter_0-1679399284692.png

 

Action parsing the payload "custom Jira Fields action"

Script step: 

(function execute(inputs, outputs) {
var data=JSON.parse(inputs.payload);
gs.info(inputs.payload);
//outputs.t_shirt=data.issue_event_type_name;
outputs.start_date=data.issue.fields.customfield_10502;
outputs.health=data.issue.fields.customfield_10911.value;
outputs.commited_status=data.issue.fields.customfield_11629.value;
outputs.end_date=data.issue.fields.customfield_10607;
outputs.t_shirt=data.issue.fields.customfield_11007.value;
outputs.review_notes=data.issue.fields.customfield_10942;
})(inputs, outputs);

 

logged to ouput variables and then the output variables mapped to fields in update statment 

PatrickSlatter_1-1679399406340.png

 

 

ANy asistance would be greatly appriciated for accomodating these NULL values. 

 

Thanks in advance!

 

1 ACCEPTED SOLUTION

Patrick Slatter
Tera Guru

Self Solved 

Need to log the null value from the object to string, for the flow variable 

Example: 

var data=JSON.parse(inputs.payload);
gs.info(inputs.payload);
outputs.start_date=data.issue.fields.customfield_10502;

if (data.issue.fields.customfield_10911==null){
outputs.health = "";
} else {
outputs.health=data.issue.fields.customfield_10911.value;
}

 

 

Needs to log the null as an empty string and then it will map to clear the field accordingly

View solution in original post

1 REPLY 1

Patrick Slatter
Tera Guru

Self Solved 

Need to log the null value from the object to string, for the flow variable 

Example: 

var data=JSON.parse(inputs.payload);
gs.info(inputs.payload);
outputs.start_date=data.issue.fields.customfield_10502;

if (data.issue.fields.customfield_10911==null){
outputs.health = "";
} else {
outputs.health=data.issue.fields.customfield_10911.value;
}

 

 

Needs to log the null as an empty string and then it will map to clear the field accordingly