[Solved] The supplied reference link is invalid in Cloudflows

Introduction:

When we add a new row in dynamics CRM, we might end up using the lookup data reterived in previous action.

There might be times when the previous record has returned a null.

In such cases we get the error-

{

  “error”: {

    “code”: “0x0”,

    “message”: “The supplied reference link — contacts() — is invalid. Expecting a reference link of the form /entityset(key).”

  }

}

For this example; I was creating a new record and wanted to use the Account and its contact as lookup in my new record. The reterived Account did not have a contact and so my flow failed.

Solution:

 Use the below if condition,

if(empty(triggerOutputs()?['body/_primarycontactid_value']), ' ',
concat('contacts(',triggerOutputs()?['body/_primarycontactid_value'],')'))

In this condition- we are checking if the reterived contact is empty, if yes we are setting the lookup field to blank else we are setting the lookup value.

Note: Please remove and add the quotes/ commas again ; if you are copy pasting the condition in your flow else it might show invalid expression.


Share Story :