Ash Flow branch condition

I'm trying to do something like this:
check if record exists
branch on record not existing
create record with linked belongs_to record
check if record exists
branch on record not existing
create record with linked belongs_to record
the branch conditions is the following:
read :get_invoice_data, MmsBiztalk.InvoiceData, :current do
get? true
not_found_error? false

input(%{
help_desk_id: path(arg(:attributes), [:help_desk_id])
})
end

branch :invoice_data_found, expr(^result(:get_invoice_data)) do
end
read :get_invoice_data, MmsBiztalk.InvoiceData, :current do
get? true
not_found_error? false

input(%{
help_desk_id: path(arg(:attributes), [:help_desk_id])
})
end

branch :invoice_data_found, expr(^result(:get_invoice_data)) do
end
The strange thing is that the branch executes even if the record is found. I understand that condition must be a boolean value. Is there a way to achieve it with a read action or I need to use a custom :get_invoice_data step?
1 Reply
ZachDaniel
ZachDaniel3y ago
Do you mean “it executes even if the record is not found? That seems right to me, but you could try expr(not is_nil(^result(:step))) Actually maybe I misunderstood. I think you might just want is_nil(…). Your step as I read it would only execute if there was something found whereas you want something where it wasnt found. @tommasop#2001 if your issue has been resolved, please add the resolved tag and close the post. No worries if it’s not resolved yet though 🙂

Did you find this page helpful?