Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Can't Pass null value to the Lookup field in Dataverse

(0) ShareShare
ReportReport
Posted on by 202

I am trying to pass the null value to the lookup field using the Power Automate.

 

I am using the below expression.

if(not(empty(variables('varEvent'))),concat('hso_events(',variables('varEvent'),')'),'')
 
This is still giving the below error.
The supplied reference link -- -- is invalid. Expecting a reference link of the form /entityset(key).
 
Any help would be appreciated.

 

  • Linn Zaw Win Profile Picture
    Linn Zaw Win 2,982 on at
    Re: Can't Pass null value to the Lookup field in Dataverse

    @looblylu25 

    I guess you are mixing up the different syntax of setting the null value.

    For your case, you are using the / syntax. e.g.

    /accounts/«GUIDValue»

    If that is the case, your expression should be as follows without the bracket characters '(' or ')'

    if(empty(triggerOutputs()?['body/_msi_backdonor_value']), '', concat('/accounts/', triggerOutputs()?['body/_msi_backdonor_value']))

    I am not sure if that will work because I have never used that syntax to set the lookup value.

     

    In my blog post, I am using the () syntax. e.g.

    accounts(«GUIDValue»)

    In that case, your expression should be as follows without the '/' character.

    if(empty(triggerOutputs()?['body/_msi_backdonor_value']), '', concat('accounts(', triggerOutputs()?['body/_msi_backdonor_value'], ')'))

     

     

  • looblylu25 Profile Picture
    looblylu25 2 on at
    Re: Can't Pass null value to the Lookup field in Dataverse

    @LinnZawWin Hi Linn, I've used your expression, which works when you need to set NULL is the actual value being passed is null, but what if the value is NOT null - this expression does not set the value to the field.

     

    If I use the standard of 

    looblylu25_0-1694016406237.png

    If the Donor(Value) is null, this expression fails with the error: The supplied reference link -- -- is invalid. Expecting a reference link of the form /entityset(key) - therefore you need an expression that will pass NULL or pass the actual value in the field. The expression I am using is:

    if(empty(triggerOutputs()?['body/_msi_backdonor_value']),'',concat('/accounts/(',triggerOutputs()?['body/_msi_backdonor_value'],')'))

     

    It works in that if the field is NULL, nothing is added to Dataverse, but it also doesn't add a value if there is data.

     

    Any ideas please? Many thanks, Lucia

  • Linn Zaw Win Profile Picture
    Linn Zaw Win 2,982 on at
    Re: Can't Pass null value to the Lookup field in Dataverse

    @Naveen_772 

    Instead of an empty string, you can set a null value. Please refer to my blog post for more details.

    https://linnzawwin.blogspot.com/2020/07/how-to-set-lookup-fields-with-null.html#updatenull

     

    Here's the updated expression.

    if(
    	not(empty(variables('varEvent'))),
    	concat
    	(
    		'hso_events(',
    		variables('varEvent'),
    		')'
    	),
    	null
    )

     

     

  • rikdekoning Profile Picture
    rikdekoning 281 on at
    Re: Can't Pass null value to the Lookup field in Dataverse

    Try using int('-1') inside your expression instead of '':

    if(not(empty(variables('varEvent'))),concat('hso_events(',variables('varEvent'),')'),int('-1'))

    Lookup fields are weird and the only way to clear them is to provide -1 as lookup ID. '' is just an empty string and won't be processed, so it will keep the current value.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard