cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NeikeDjour
Level: Power Up

Value from Array

When I'm Filtering an Array, I use Select to get the item I'm looking for. It's outputting something like:

 

{

"Time Off Start Date": "43612"
}
 
When I go to compose or set a variable from this, it gives me the entire string. How do I set just the value '43612'?
1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Value from Array

@NeikeDjour 

Thanks for the info!

This error means the output of your Select is not an object, but an array of objects (an array of one object, more precisely)

So, when initializing variable auxObject you can declare it with the following expression:

 

first(YOUR SELECT OUTPUT HERE)

 

first() takes the first element from the array

 

In this screenshot, you will see I simulated your Select output by means of a Variable called outputSelect:

 

flow_object_property.png

 

This is the result after execution

 

flow_object_property_2.png

Hope this helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





View solution in original post

11 REPLIES 11
Super User
Super User

Re: Value from Array

You need to use the Parse JSON action, with this Flow will recognize your data and properties.
You can see example here: http://johnliu.net/blog/2018/6/a-thesis-on-the-parse-json-action-in-microsoft-flow

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

Gustavo Moraes, o astronauta brasileiro do Flow!


Dual Super User
Dual Super User

Re: Value from Array

@NeikeDjour 

Let's see if I understood it properly:

 

When I go to compose or set a string variable from the output of your select, the result is

{
"Time Off Start Date": "43612"
}

 

If so, it looks like SElect output gives you an object.

I would suggest you to do the following:

Initialize an variable of type object with the Select output. Let's call it auxObject

Once you define it you can obtain the string value '43612' just by using the expression variables('auxObject')?['Time Off Start Date']

 

Hope this helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





NeikeDjour
Level: Power Up

Re: Value from Array

What should I be adding to the JSON Schema? When I set it to parse, I'm getting the same output.

NeikeDjour
Level: Power Up

Re: Value from Array

@efialttes

I get this error:

 

The variable 'Time Off Start Date' of type 'Object' cannot be initialized or updated with value '[ { "Time Off Start Date": "43612" } ]' of type 'Array'. The variable 'Time Off Start Date' only supports values of types 'Object'.

Super User
Super User

Re: Value from Array


@NeikeDjour wrote:

What should I be adding to the JSON Schema? When I set it to parse, I'm getting the same output.


Hey @NeikeDjour 

Click in use a sample and put inside it your example,

 

After you will see your property like prints belowFlow 1.jpg

 

Flow 2.jpg

 

Flow 3.jpg

 

Your result show be that:Flow 1.jpg

 


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

Gustavo Moraes, o astronauta brasileiro do Flow!


Dual Super User
Dual Super User

Re: Value from Array

@NeikeDjour 

Thanks for the info!

This error means the output of your Select is not an object, but an array of objects (an array of one object, more precisely)

So, when initializing variable auxObject you can declare it with the following expression:

 

first(YOUR SELECT OUTPUT HERE)

 

first() takes the first element from the array

 

In this screenshot, you will see I simulated your Select output by means of a Variable called outputSelect:

 

flow_object_property.png

 

This is the result after execution

 

flow_object_property_2.png

Hope this helps





If anyone is trying to help you with an issue, the fastest way to say thanks is by kudoing. Be grateful, Thumbs up!

Proud to be a Flownaut!





View solution in original post

NeikeDjour
Level: Power Up

Re: Value from Array

@gamoraes 

 

I got this:

Screen Shot 2019-05-24 at 12.02.22 PM.png

Super User
Super User

Re: Value from Array

Use all select body to generate the schema and will work:
Use this:
[ {

"Time Off Start Date": "43612"
}]

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

Gustavo Moraes, o astronauta brasileiro do Flow!


NeikeDjour
Level: Power Up

Re: Value from Array

@gamoraes 

Sorry, I'm really not familiar with this at all. You want me to put the output of 'Select' into the schema? I tried that the first time and it just output the same thing I input.

NeikeDjour
Level: Power Up

Re: Value from Array

@gamoraes 

I got:

InvalidTemplate. Unable to process template language expressions in action 'Parse_JSON' inputs at line '1' and column '2575': 'Unexpected token encountered when reading schema. Expected StartObject, Boolean, got StartArray. Path 'schema'.'.
Highlighted
NeikeDjour
Level: Power Up

Re: Value from Array

@efialttes 

Actually that's exactly what I was looking for. Thanks!

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 (Last 30 Days)
Users online (4,795)