cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sjcitpro
Level: Powered On

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
Community Support Team
Community Support Team

Re: Help with understanding variables

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
Level 8

Re: Help with understanding variables

@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. 

Community Support Team
Community Support Team

Re: Help with understanding variables

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

Highlighted
sjcitpro
Level: Powered On

Re: Help with understanding variables

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 362 members 5,868 guests
Please welcome our newest community members: