cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sjcitpro
Helper III
Helper III

Help with understanding variables

I need to understand how to obtain variables with Get_items.  Seems my options are List of Items and value.  Value gives me body('Get_items')?['value'] i tried Initialize variable with tolower(concat(substring(body('Get_items')?['Firstname'],0,1),body('Get_items')?['Title'])) but get an error of NULL value.  

 

Untitled.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

Hi @sjcitpro ,

 

We can traverse the information contained in each item obtained by Get items in Apply to each.

Basically, when configuring Value is in Initialize variable action, the available Dynamic content is automatically displayed according to the Type you set.

 

For example, if you initialize an array variable, then only the value, as below:34.PNG

 

If you want to get Title and other field value contained in the item and concat them to the value of the variable, you could set the type to String.

At this time, we need to use Apply to each and Set variable action, traversing the Body returned by Get items and assigning values to variables need to use Apply to each, but Initialize variable action cannot be done in Apply to each.37.PNG

 

Expression:

tolower(concat(substring(item()?['Firstname'],0,1),item()?['Title']))

Another way to consider is to use Compose, as shown above.

 

Hope it helps.

 

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
SamPo
Power Participant
Power Participant

@sjcitpro You need to use the correct string of values. For you it should look something like this:

 

body('Get_items')?['value'][0]?['Title']

Notice the [0] selects the first object in the array 'value'. If you want to cycle through every object in the array (if there are multiple results) then you need to use 'apply to each'. For only one value just use the [0] to select the first value in the array.

 

The easiest way to see what the correct syntax should be is choose a value directly from the 'dynamic content' window like 'title' for your variable. It will automatically put your variable inside an apply to each. You can then look at the formula it provides for the apply to each and for your variable to see what the correct syntax should be. 

v-bacao-msft
Community Support
Community Support

Hi @sjcitpro ,

 

We can traverse the information contained in each item obtained by Get items in Apply to each.

Basically, when configuring Value is in Initialize variable action, the available Dynamic content is automatically displayed according to the Type you set.

 

For example, if you initialize an array variable, then only the value, as below:34.PNG

 

If you want to get Title and other field value contained in the item and concat them to the value of the variable, you could set the type to String.

At this time, we need to use Apply to each and Set variable action, traversing the Body returned by Get items and assigning values to variables need to use Apply to each, but Initialize variable action cannot be done in Apply to each.37.PNG

 

Expression:

tolower(concat(substring(item()?['Firstname'],0,1),item()?['Title']))

Another way to consider is to use Compose, as shown above.

 

Hope it helps.

 

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

How about this one. I am trying to use Middle Name in an Expression.  I have tried if(equals(items('Apply_to_each')?['Middle_x0020_Name'], null) and if(equals(items('Apply_to_each')?['Middle Name'], null) with no luck.

 

Untitled.jpg

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!

Users online (5,688)