cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SentiNode
Level: Powered On

How to check for emtpy collection or for existence of data row in Common Data Model database

Hi,

 

I need to verify if a row with certain ID exists in the table, if yes - run one command chain, if no - insert the new value and run another command chain.

 

I do the Get entity data with a filter, but then if I try to add a condition, it automatically changes to "apply to each", and tries to iterate over "values", comparing the value to null does not work (it is always not null), trying to compare some column within the row to be returned does not work - both yes/no options are skipped.

 

Any ideas?

17 REPLIES 17
Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Hi SentiNode,

 

You have to use the advanced mode in the condition expression and use the @empty Logic app expression https://aka.ms/logicexpressions 

 

Here's a flow that demonstrate it - be sure to click on the advanced mode in the filter array to enter this value

 

photo.PNG

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Actually I would like to do :

Get Entity Data (with a correct filter) ------>  Condition  [Yes block | No block].
 
How should I properly use @empty to verify if Get Entity Data returns an empty collection or an actual object?

 

The Filter Array -> Apply to each, wouldnt be the best solution here:

 

1)  I will get either a single result (the object exists in a table) or no results (the object does not exist in a table)

 

2) I it does not exist - I want to create it, if it does exist however - I want to update it and increase update counter in the object.

Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

You should be also able to use the empty expression in a condition card (without the filter array) and detect if the object exists or not - Go into the advanced mode.

 

Let us know if this adresses it.

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

I did, but it goes one way always (empty) regardless of the actual array

Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Hi SentiNode,

 

To be clear, your flow should look like so, fill in the Yes/No paths to do what you want. This does not work?

 

pic.PNG

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Id do not have "apply to each" box, can I check directly the results of Get Entity Data if there were some results??

Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Unfortunately, GetEntity data does not support a filter today.

 

Can you clarify what you mean by "do not have "apply to each" box?

 

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Hmm, why can I set a filter in GetEntity then?

Directly after get entity I have the condition, not using "apply to each" to encircle it.

 

flow.png

Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Can you replace GetEntity by GetList of Entities, post that you should be able to apply the foreach like how I listed.

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Get entity data returns the list on the matching entities... is there any debug to see the data structures that are actually passed? Maybe it returns an array of array objects?
Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

It does return an array of objects (collection). Configure it and run, if you click on the i link on your flow list, you should see all the parameters being passed in for a flow run

 

https://flow.microsoft.com/manage/flows

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

When I click on the link (arrow) nbothing happens...

 

How do I check if the collection returned by "Get entity data" is empty or not? should I reference item()? or something else ? I really can't see what is passed between the nodes so it is pretty hard to create conditions in advanced mode...

Mir_Hassan_Ali
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Hi SentiNode

 

Did you get a solution to this issue, I am also facing a similar situation.

 

Thanks

 

Mir

SentiNode
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Still no info on that?


Any way to check what variables are passed between the nodes? Any debug? When I click on the link between nodes I get no information about the variables passed.

Flow Staff RajRa
Flow Staff

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Hi SentiNode,

 

To be clear, did you go to this page by clicking on the i as shown in this picture and eventually you should be able to see each individual run - Is this not working for you?
i.png

SROY
Level: Power Up

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

Following is a working solution.

 

flow_EmptyCheck.png

me36835
Level: Powered On

Re: How to check for emtpy collection or for existence of data row in Common Data Model database

grafik.png

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 209 members 4,007 guests
Please welcome our newest community members: