cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NeikeDjour
New Member

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

@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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

11 REPLIES 11
gamoraes
Memorable Member
Memorable Member

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!


efialttes
Super User
Super User

@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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



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

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


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


@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



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



@gamoraes 

 

I got this:

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

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!


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

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

@efialttes 

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

Helpful resources

Announcements
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 tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Users online (3,162)