0

I am calling the SP API to get the version history of an item in my list as follows:

 _api/web/lists/getbytitle('@{triggerBody()?['SPListName']}')/items(@{triggerBody()?['SPListID']})/versions?$top=20

I am getting the values and parse them with a JSON parser as explained here,

I can get all the values of the columns of my list without any issue, however I have a multi-choice column which returns the below string as the result of the Parse JSON action

 {"__metadata":{"type":"Collection(Edm.String)"},"results":["Choice 2"]}

if I select two choices in my multi-choice column, I get the below result:

{"__metadata":{"type":"Collection(Edm.String)"},"results":["Choice 1","Choice 3"]}

How can I only get the value in the "results" section as a string such as "Choice 1","Choice 3" rather than the whole metadata string

1

Updating for [Send a HTTP..] request. Here [results] is an array, and [MyChoice] is also an array.

body('Parse_JSON')?['d']?['results'][1]['MyChoice'][0]['Value']


Here's how I can find individual choice value when retrieving list items using [Get items] -> [Parse JSON] -> [Apply to each]

Here for each item, [MyChoice] is the Property (column name of the multi-value), and [0] is the index of the first value. You can check the length of [MyChoice] and dynamically find each value.

items('Apply_to_each')['MyChoice'][0]['Value']

enter image description here


Updating the answer showing how to dynamically capture values from a multi-value column

Please see the screenshots and explanation below.

Please note that it's very important to analyze the output from [Send an HTTP..] by using a [Compose] action before feeding into [Parse JSON]

enter image description here

Detail Apply to each 2 enter image description here

Detail - Loop for Choices per item (inner loop) enter image description here

Detail 3 enter image description here

8
  • Thank you, How can I check the length of MyChoice dynamically?, can you show me a code or screenshot to iterate through MyChoice and get each value and append it to an array based on the output of Parse JSON? – Mohsen Sichani Oct 22 '20 at 18:42
  • I am doing it by if(greater(indexof(string(items('Apply_to_each_History_Parse_JSON')?['BudgetSource']),'['),1),replace(replace(replace(string(items('Apply_to_each_History_Parse_JSON')?['BudgetSource']),'{"__metadata":{"type":"Collection(Edm.String)"},"results":[',''),']}',''),'"',''),''), but any better solution? – Mohsen Sichani Oct 22 '20 at 20:01
  • I'm almost done posting the update.. give me a few minutes – Matiur Rahman Oct 22 '20 at 20:21
  • Sure thanks a lot, no rush – Mohsen Sichani Oct 22 '20 at 20:43
  • Update completed. Note that there are two loops, one at the item level and within that the loop for choices of each item. Since you know the length of the [MyChoices][results], you can use [Do Until] loop as well. It depends how you want to use it. But let me know if you have any further questions – Matiur Rahman Oct 22 '20 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.