cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
russrimm
Microsoft
Microsoft

Choices, xpath, & [Brackets]

Hi all, I'm using xpath(xml(json(concat('{"root":{"choices":', item()?['MyValue'] , '}}'))), '/root/choices/Value/text()') to return an array from my Sharepoint list for each Choices column type and adding it to an HTML table.

When the values appear for each of the Choices columns, they appear in the HTML table as ["Value1","Value2"] but I want them to appear as Value1, Value2.

I've been trying to use replace unsuccessfully, so far, to strip out the brackets and quotes around each of the values so only the value itself is returned. ?

Thanks in advance!

10 REPLIES 10
DeepakS
Resident Rockstar
Resident Rockstar

Hi @russrimm 

 

If you are getting results as  ["Value1","Value2"] you can assign it to an array variable to get each value as you expected.

Array.png

 

Now being said that i am not sure if this is your issue, if not please share a screen capture and a bit more details of your flow.

 

 

Thanks Deepak, I can get them into an array, I guess what i'm not sure if is once I get them into the array how to get them into my html table without the [""] around the values.  I can't initialize an array variable in an Apply to Each, so it seems like ultimately I need to somehow initialize the array and join the values with a comma and then insert that into each row in my html table just to get rid of the [""].  When I try to initiailze the array it automatically adds an apply to each and then I get an error letting me know I can't initialize an array in an apply to each.  My first step is a "Get sharepoint items" and then 3 of the columns are a "Choices" type and may have more than one value.  Those are the ones i'm trying to strip the brackets and quotes from when they're added to my html table.

DeepakS
Resident Rockstar
Resident Rockstar

Hi @russrimm 

 

Can you share a screen capture of the flow so i can understand /help you better.

 

-----------------------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

v-bacao-msft
Community Support
Community Support

 

Hi @russrimm ,

 

Please try to use Join to remove brackets and quotes, since that it is an array.

192.PNG193.PNG

Hope this 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.

If I try doing an initialize variable of the Array type, as soon as I add my "Choices" column, it automatically adds an Apply to Each step and then tells me that I can't have an initialize array as the first step in an Apply to Each.  I just want all the choices they selected (the choices columns allow multiple selection) to show in the CSV and HTML tables without the ["   "] around them, otherwise it's working OK as it is.  It just gets the items and adds them all to a csv and html, but the Choices columns are always adding the [" "].

@russrimm  could you share an screanshot to understand better?



Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

 

Hi @russrimm ,

 

I remember that I have responded to this question and provided some suggestions in the email message you sent me. Please check it.

 

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.
Exon02
New Member

@russrimm 

 

i'm having the same issue how did you resolve it? Please share.

Thanks in advance!

Hi @Exon02 I ended up changing the column type to text and using comma delimited values with Split.  I've learned to avoid using Choice column types more.

arghhh
Regular Visitor

@russrimm @Exon02 

Add join to your xpath to set your delimiter at the end of the expression.

 

join(xpath(xml(json(concat('{"root":{"choices":', item()?['MyValue'] , '}}'))), '/root/choices/Value/text()')', ')

 

Or for example pulling a DisplayName out of a people picker.

 

join(xpath(xml(json(concat('{"body":{"value":', item()?['value'], '}}'))), '/body/value/DisplayName/text()'), ', ')

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (2,558)