Only insert deceased Person if deaths >0
Closed this issue · 5 comments
Need to add a line to only run this part of the job if deaths > 0
(where deaths
is the array we defined in alterState). Can you help me out here? Have tried a few variations and can't seem to get it to work :-)
@taylordowns2000 I'm still struggling to getting upsertIf()
to work here and spending way too much time. Can we walk through tomorrow?
I'm finding the upsert always executes even if the logical is false. I'm wondering if it has something to do with this upsertIf
being nested under merge()
...
If I try this expression but add in upsertIf
(see one of many variations I tried below), and run it with this state.json (where "deaths_in_past_6_months" : "0"
)--> it still upserts a Person record when it should not because logical is false.
upsertIf(state => {
var deaths = state.data.form.household_deaths.deaths_in_past_6_months;
return (deaths > 0 ? true : false);
},
"Person__c", "CommCare_ID__c", fields(
Resolved with TD suggested change. Added to new job to run in parallel with this job to support 2 live CommCare form versions: bd2f041