web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using an if expression...
Power Apps
Answered

Using an if expression to conditionally add a lookup record

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I'm building a flow to transfer data from SQL Server to Dataverse.  I'm creating contact records and each contact may have a supervisor.  If a supervisor exists I want to add a lookup to the new contact record, but if not I want to do nothing.  I know how to do this using the conditional actions in flow, but I'd prefer to use an expression in the lookup field for the Add a new record Dataverse action to minimize the business of the flow.  Ideally, I'd like something on the order of:

 

if(equals(variables('id'),''),'',/contacts(variables('id')))

 

The intent of the above is that when the id retrieved for the supervisor is empty, don't add a lookup, but if there's a value add the contact lookup using that id.  The above gives an invalid expression result when I try to apply it.  If anyone can help me out, or indicate if this method can't work, I'd appreciate it.

 

Thanks!

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    3,306 Most Valuable Professional on at

    Hello,

    Try to use

    if(equals(variables('id'),''),null, Concat('/contacts(', variables('id'), ')')))

  • dms117 Profile Picture
    on at

    Thanks for the advice!  The formatting worked and the expression builder accepted this.

     

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard