The Get-Or-Create Use-Case
Get-Or-Create is a very common use case.
The client sends invoices with an accountNo (number). Your process must check if the accountNo exists and get the account's id, or it creates a new account for the given number. In any case, the process needs the internal accountId (record-id) to continue processing the invoice: createInvoice( invoiceNo, accountId)
AccountNo --> get (accountNo)
:ok --> accountId
:failed--> create (accountNo) --> accountIdIf you consider an input profile like this: j.Invoice.REQ
{
"InvoiceNo": "I003-3",
"AccountNo": "ACC009",
"ToalAmount": 2300,
"InvoiceDate": "2024-02-28"
}You will notice that having the acountId as a Dynamic Document Property attached to the document would be a perfect solution, to create an Invoice:
DDP_AccountId = 69d38081-3c43-41f8-b3d7-34cb9516eefe

Unfortunately the implementation is not as easy as it seems, and the proposed solution won't work: the reason is that at the end of Branch 1 the account response incl. the accountId are discarded and they are no longer available on the beginning of Branch 2 where you need the accountId to create the invoice.The Cache Challenge.
if you then need the created invoice's id, too, for the j.Invoice.RES response, you are into trouble. The solution follows: PropCache Scripts
Last updated