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

LOGIC APP - INVALID USE OF NULL - ARRAY

Team,  I am building out a logic app with an HTTP Request to start that has varying "inputs" to it. The issue I am having is sometimes it has "an array" and sometimes it does not for when a document exists. If a document exists all of the logic I have works great. I have tried to use "empty" and convert to string and replace empty with {} .... and other suggestions. It makes it past all of that and I still get the same message.    - ExpressionEvaluationFailed. The execution of template action 'For_each_2' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?['eventData']?['stop']?['documents']' is of type 'Null'. The result must be a valid array.

 

I need to finish a project and this is the last leg. See images... Please help :Logic app image 1.PNGLogic app image 2 error.PNG)

1 REPLY 1
Paulie78
Super User
Super User

You could use an expression like this:

if
(
  equals(triggerBody()?['eventData']?['stop']?['documents'], null), 
  json('[]'), 
  triggerBody()?['eventData']?['stop']?['documents']
)

Which basically says if the array is null (i.e. it does not even exist in this case). Then substitute it with an empty array, which will stop the error.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,874)