cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jronash
Impactful Individual
Impactful Individual

Difference between item()['key'] and item()?['key']

Kind of a basic question, but I don't have the vocabulary to put together a proper Google search to answer my question.

 

Basically, there seems to be two different ways of referring to a key or item within an array or JSON object.  One way is like this:

item()['key']

The other is the same, but has a question mark:

item()?['key']

(of course "item()" could be replaced with anything that is an object or an array)

 

I've seen both methods used in different tutorials, and in most cases in my personal use, it seems like there are some instances when either method works.  BUT I have run into situations where one method works, but not the other.

 

So what's the difference?  How do I know whether or not to include the question mark?

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Jcook
MVP

Hello @Jronash 

 

The ? Is there for handling instances where the value cannot be found. The ? Returns a null value rather than throwing an error.


This post has a great example:

https://powerusers.microsoft.com/t5/General-Power-Automate/Use-of-Question-Mark-in-expressions/td-p/...


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





View solution in original post

1 REPLY 1
Jcook
MVP

Hello @Jronash 

 

The ? Is there for handling instances where the value cannot be found. The ? Returns a null value rather than throwing an error.


This post has a great example:

https://powerusers.microsoft.com/t5/General-Power-Automate/Use-of-Question-Mark-in-expressions/td-p/...


Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (1,634)