The supplied reference link is invalid Error 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)."

  }

}

 

Graphical user interface, application

Description automatically generated

 

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. 

 

Text

Description automatically generated

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.


Comments

Popular posts from this blog

Retrieve Email Recipients (TO, CC, BCC) in Cloud Flow

Set Dynamic Recipients of D365 Email in Power Automate