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 ACCEPTED SOLUTION

Accepted Solutions
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.

 

 

 

 

View solution in original post

2 REPLIES 2
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.

 

 

 

 

wmelonMan
Regular Visitor

@ekarim2020 , thanks a lot for the detailed explanation. That made it very clear to me!

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,467)