I'm not sure what to make of this one, I've got a firestore query that I run to insert a new document when triggered.
"type": "paidClaimCalculation",
"eventTime": {{ moment(new Date()) }},
"data": {{updatedChecklist.value}},
The issue appears to be in the transformer updatedChecklist
I have a custom component that maintains the state on a checklist the user can interact with, that all appears to be working just fine it's represented in the UI correctly and the model is updating as it should. But when I go to run the insert query the transformer does not return the correct value. What's even stranger is that I can get it to return the correct value, by adding a reference to the component that does nothing before I actually get the value.
const checklistComponent = {{customChecklist}};
const updated = {{ defaultOrLatest.value['0'] }};
const updatedChecklist = {{customChecklist['0'].model.items}};
updated['checklist'] = updatedChecklist;
return updated;
This code above works, the updated value gets pulled from customChecklist['0'].model.items
and inserted correctly.
const updated = {{ defaultOrLatest.value['0'] }};
const updatedChecklist = {{customChecklist['0'].model.items}};
updated['checklist'] = updatedChecklist;
return updated;
This code doesn't work, for some reason the updatedChecklist value is always the previous value in this case. I also figured out that the following code works too
console.log({{customChecklist}});
const updated = {{ defaultOrLatest.value['0'] }};
const updatedChecklist = {{customChecklist['0'].model.items}};
updated['checklist'] = updatedChecklist;
return updated;
Is there some kind of caching going on with the transformer/component? When I preview the transformer in the UI I see the correct values, and if I run the preview it returns the correct values. But if I trigger the transformer by running the insert query that is where it seems to have the previous value. Does the value of that transformer get decided when the query is initialized? So it's not actually getting the new value?