Setting a lookup field in Power Automate
In this post, a Transaction Log record will be assigned to a Receipt record’s Transaction Log lookup field.
Note: the scope of the post is for the CDS (current environment) connector.
Firstly, it’s necessary to determine how a transaction log record is referenced in Power Automate i.e. its syntax. To do this, create a simple ‘dummy’ Power Automate flow that performs a ‘Get’ on the Transaction Log entity.
As illustrated in the screenshot below, the transaction log entry is referenced as:
Now, with this key piece of information, the Power Automate flow example which sets a lookup field in the receipt record, can be created as follows.
The flow is triggered by a HTTP POST with a JSON payload. Within the JSON payload, the field paymenttransactionlog contains the value abcdyn_transactionlogs(ec1eea6b-673b-eb11-a813-000d3ad1c24a)
When creating the receipt record, the following expression is added to the Transaction Log lookup field.
if(empty(string(triggerBody()?[‘paymenttransactionlog’])), null, string(triggerBody()?[‘paymenttransactionlog’]))
When the flow is executed, the Transaction Log lookup field (within the newly create receipt record) contains the values
It’s as simple as that!
(Note: At the start of this post, we performed a ‘Get’ on the transaction log. If we had decided to keep that in the flow, then we could have assigned the ‘Transaction Log’ lookup following the same format as ‘Client in Session’ and ‘Invoice’ shown below.) That is, using dynamic content.