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

Systematics for referencing properties

Why is it, that retrieving a property of the triggerBody object requires a questionmark - triggerBody()?['SomeValue'- while getting a property of the current loop object - items('Apply_to_each')['SomeValue'] - goes without it?

EDIT: Just was pointed to the answer in another topic - understood. Yet the following questions are still valid:

 

Is there a tutorial or documentation or online course out there explaining basic concepts like these from scratch? I am tired to work my way through things like these by doing countless google searches...

EDIT: Found the Azure Docs but that's way to dry. I would need some examples or use cases.

 

Also I am haunted by things like "wrapper object for batch trigger response" or simply "value - A list of the response objects" which appear as dynamic content when I start building an expression 😨. Would I ever use these? And if - how?

 

The screenshots show OnNewEmailV3 with SendEmailV2 in the second step (german).

wmelonMan_0-1653130549796.png  

wmelonMan_1-1653130653586.png

 

 

1 REPLY 1
ekarim2020
Super User
Super User

Hi @wmelonMan ,

 

I've seen articles and training courses use different JSON "notations". New developers (including myself) assumed that the different notations were the same, it was just a matter of preference. The writers or trainers do not elaborate any further - perhaps they think it may be too confusing for a beginner?  

 

May be the following examples will help.

 

Example 1

Snag_f8b9476.png

 

variables('varData')?['name'] ➡️ C-3PO
variables('varData')['name'] ➡️ C-3PO
variables('varData').name  ➡️ C-3PO

 

Example 2: variables('varData')?['name']

The name property is missing from the data:

Snag_f9a7d7a.png

variables('varData')?['name'] returns an empty value:

Snag_f9517b3.png

The flow does not produce an error and the flow continues.  Your flow may need some logic to handle the empty value (e.g. if it is a value, like age or currency).

 

Example 3: variables('varData')['name']

The name property is missing from the data:

Snag_f98b3d6.png

variables('varData')['name'] ➡️Flow stops with anError
variables('varData').name ➡️ Flow stops with anError

 

Snag_f92b068.png

 

However, the error message is actually very useful and tells us that the name property is missing from the data:

Snag_fb64868.png

'The template language expression 'variables('varData')['name']' cannot be evaluated because property 'name' doesn't exist, available properties are 'height, mass'. 

 

So most of the time in your flows you would use the notation variables('varData')?['name'] .

 

However, as we have seen there are times when the other notation (variables('varData')['name']) can useful in testing and debugging a flow. You may want to generate an error and stop the flow so that you can identify the error and correct it. You may have mistyped a property or the property may be missing and you are seeing empty data values in your flow.  You may need some additional logic to handle the empty or missing values or fix the source data.

 

I know that @DamoBird365 is quite an expert in this area.

 

Ellis
____________________________________
If I have answered your question, please mark the post as Solved.
If you like my response, please give it a Thumbs Up.

 

 

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

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

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

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