cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Condition displays "The input array was empty." and does not execute true path

Basically, I'm trying to retrieve a Contact record from Dynamics CRM. If the record is null/false, I want to do something. If the record is found/true, I want to do something else. Right now, if the CRM record is null, the Flow seems to end with the "The input array was empty" message. If the record is found, it executes the false branch of the condition.  

 

Flows_question2.PNG

Here is my condition.

 

Flows_question4.PNG

 

Here are some of the statements I've tried.

 

@empty(body('List_records'))

@greater(length(outputs('List_records')),0)

 

Seems like something that should be extremely easily to handle. Does anyone know how to get this to work?

 

Thanks! Any help is much appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions

@faustocapellanj This statement works! @if(empty(body('List_records')?['value']),True,False)

 

Thanks for your help working through this. Removing the "Apply to each" step was part of the process.

View solution in original post

9 REPLIES 9
Memorable Member
Memorable Member

Hi @dumber_texan2,

 

Can you try the expression below in the Condition? You can either do 1=true or 0=false.

@equals(length(outputs('List_records')),0)

 

Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

@faustocapellanj Thanks for the help. I tried that. Here is the error message.

 

InvalidTemplate. Unable to process template language expressions for action 'Condition' at line '1' and column '1580': 'The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Object'. Please see https://aka.ms/logicexpressions#length for usage details.'.

 

Based on this comment "You can either do 1=true or 0=false" I'm concerned that Microsoft Flows doesn't have a true or false option for my use case. Is this correct?

 

Basically, I'm looking for something like this.

 

if ('List_records' = null)

{

 //Do this.

}

else

{

 //Do this other thing.

}

 

Thanks!

Hi @dumber_texan2,

 

Move the condition outside the Apply to each step and do the same expression I suggested, but do the 1 instead of the 0 so it can return true. Once you do that, then the Apply to each step will be added automatically to the Yes or No step. Let me know how that goes.

 

Regards,

Fausto Capellan, Jr

Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

@faustocapellanj Thank for your continued support on this. Everything now evalutaes as false. I can't get a true result. "The input array was empty" message has gone away. Any other ideas? I can't believe this isn't more straightforward.

Memorable Member
Memorable Member

What's the Output on the List records step? Can you please post a screenshot of that output? You can see what comes back from the query, which will give you an idea on how to build the expression for the condition. Please let me know what you get.
Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

@faustocapellanj This statement works! @if(empty(body('List_records')?['value']),True,False)

 

Thanks for your help working through this. Removing the "Apply to each" step was part of the process.

View solution in original post

Memorable Member
Memorable Member

That's awesome. I'm glad that it works.

Regards,.
Fausto Capellan, Jr
Fausto Capellan, Jr
Did I answer your question? Mark my post as a solution! Did my response help? Please give it a thumbs up!

I'm having this same issue. I tried the solution but I'm getting an error. Are you able to post an image of the solution?

Basically, I'm doing a lookup in "List reocrds". Since I don't know if "List records" is going to find anything, then I have the condition.

 

@if(empty(body('List_records')?['value']),True,False)

 

If "List records" finds a record, then the above condition evaluates as False. If "List records" doesn't find a record, the above condition evaluates as True.

 

If False, then it hits the False branch. If true, then it hits the True branch.

 

Hope this helps. For some reason, I can't post an image.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (11,558)