cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mick282
Helper III
Helper III

How to null lookup fields in CDS

Hi all,

 

I've run into a problem with lookup fields in CDS and Flow. I'm trying to create a Flow which pseudo clones an existing case when they trigger a button on the form. It will then take a few fields on the existing case and create a whole new case and then roll up the existing case to the new case via the out of the box Parent Case field. 

 

The problem I'm having is that I have a custom lookup field on case called "Account" which looks up the account entity. I've then used the Common Data Service (current environment) create record step to create a duplicate of the case.

 

Now with the current environment steps. To set a lookup field for account as an example I have to set it like so:

/accounts(<account id>). This works fine but the account field is not mandatory and hence can be blank but I have to set the field value in case it has value. The problem is that if I trigger the Flow without a value in the account field. The Flow will attempt to clone the existing case and pass a blank lookup value to the field:

/accounts()

 

image.png

 

Is there a way to still have a dynamic value set for the account lookup field but if the existing case does not have a value for it, then to just set the field to null instead of failing the entire flow?

2 REPLIES 2
yashag2255
Dual Super User II
Dual Super User II

Hey @Mick282 

 

One way I see of doing this is using the coalesce function so you can do something like this: 

 

Add a compose action and save the accound field over there (i am assuming this would be a guid) and now in the action (the screenshot that you have shared), remove everything from that area and then use the expression 

coalesce(outputs('Compose'),outputs('Compose'),null)
 
This basically checks if the account field data has a value and if yes uses that value and if no then sends a null.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Digit89
Helper I
Helper I

You can use the CDS "Unrelate Record" action as a workaround while MS fix the possibility to set a null value.

Reference.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,751)