cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cmanning
Helper III
Helper III

Convert Object to an Array Within an Apply to Each

I have a flow that retrieves all items from a SP list which contains several columns of multi-select choice columns and converts to the Dataverse equivalent as it inserts new rows.  As it retrieves all the items from the multi-select choice column, I am performing certain actions.  One of the things I need to do is convert the "Resource Types" multi-select choice object to an array so I can perform additional actions.  The flow run is shown below and fails later because I am trying to perform an action on an array but it is an object that must converted to an array first. 
DI App Flow - Convert Object to Array for Multi-Select Choice cols ERR.png
Shown above is the Compose action showing that "Resource Types" is an object and I need to convert it to an array.  Below is the full code for the object.  

 

[
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 0,
        "Value": "Bid Manager"
    },
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 1,
        "Value": "Solution Consultant"
    },
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 7,
        "Value": "Legal/Contract"
    },
    {
        "@odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
        "Id": 6,
        "Value": "Pricer"
    }
]

 

Since I need to convert the object to an array within an Apply to each, what is the best method?  The new array in this instance should be as shown below.

[
  "Bid Manager",
  "Solution Consultant",
  "Legal/Contract",
  "Pricer"
]
1 ACCEPTED SOLUTION

Accepted Solutions
ekarim2020
Super User
Super User

Your data is already an array; it's an array of JSON objects.

If I have understood correctly, you want to extract the Value property from the JSON array. The result will be an array of strings:

[
  "Bid Manager",
  "Solution Consultant",
  "Legal/Contract",
  "Pricer"
]

 

To do this, please try:

Snag_53a18ea.png

 

This is the runtime output:

Snag_53ac651.png

Hope this helps.


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

 

View solution in original post

3 REPLIES 3
ekarim2020
Super User
Super User

Your data is already an array; it's an array of JSON objects.

If I have understood correctly, you want to extract the Value property from the JSON array. The result will be an array of strings:

[
  "Bid Manager",
  "Solution Consultant",
  "Legal/Contract",
  "Pricer"
]

 

To do this, please try:

Snag_53a18ea.png

 

This is the runtime output:

Snag_53ac651.png

Hope this helps.


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

 

@ekarim2020 - Ellis thanks again for another solution!! It is much appreciated. 

I'm having a similar issue, but using the 'select' method is throwing an error. 

 

The execution of template action 'Select' failed: The evaluation of 'query' action 'where' expression '@item()?[body('Parse_JSON')]' failed: 'The template language expression 'item()?[body('Parse_JSON')]' cannot be evaluated because property (here it just lists the entire json so it does not seem to pick up the properties)

 

here is the schema

 

[
    {
        "key": "RecordCategoryIdentifier",
        "type": "StringType",
        "value": "EML-99"
    },
    {
        "key": "RecordCategory",
        "type": "StringType",
        "value": "EML-99: Other"
    },
    {
        "key": "DispositionAuthority",
        "type": "StringType",
        "value": "North Systems Enterprise Retention Schedule"
    },
    {
        "key": "ContentVersion",
        "type": "StringType",
        "value": "1.0"
    },
    {
        "key": "Author",
        "type": "StringType",
        "value": "David.Whitehead@recordpoint.com"
    },
    {
        "key": "SourceCreatedBy",
        "type": "StringType",
        "value": "David Whitehead <David.Whitehead@recordpoint.com>"
    },
    {
        "key": "BarcodeValue",
        "type": "StringType",
        "value": ""
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|FileLeafRef",
        "type": "StringType",
        "value": null
    },
    {
        "key": "DisposalApprovedBy",
        "type": "StringType",
        "value": null
    },
    {
        "key": "DisposalApprovedDate",
        "type": "StringType",
        "value": null
    },
    {
        "key": "DisposalApprovalComments",
        "type": "StringType",
        "value": null
    },
    {
        "key": "DisposalRequestedApprovers",
        "type": "StringType",
        "value": []
    },
    {
        "key": "DisposalComments",
        "type": "StringType",
        "value": null
    },
    {
        "key": "SourceCreatedDate",
        "type": "StringType",
        "value": "2021-12-23T19:21:21.0000000Z"
    },
    {
        "key": "SourceLastModifiedBy",
        "type": "StringType",
        "value": "David Whitehead <David.Whitehead@recordpoint.com>"
    },
    {
        "key": "SourceLastModifiedDate",
        "type": "StringType",
        "value": "2021-12-23T19:26:23.0000000Z"
    },
    {
        "key": "Location",
        "type": "StringType",
        "value": "https://outlook.office365.com/owa/?ItemID=AAMkADA5NTU4ZTU3LTNjY2QtNGIzZi05ODFkLTNhMzc4MTUyNmJkZABGAAAAAACMpkaS11%2FNTqTLtvmiWnQzBwAjP%2FxRBovaQqMvXweXdYchAAAAAAEMAAAjP%2FxRBovaQqMvXweXdYchAAMAlkH5AAA%3D&exvsurl=1&viewmodel=ReadMessageItem"
    },
    {
        "key": "MediaType",
        "type": "StringType",
        "value": "Electronic"
    },
    {
        "key": "Title",
        "type": "StringType",
        "value": "File-Plan Import Scripts"
    },
    {
        "key": "Format",
        "type": "StringType",
        "value": "Email message"
    },
    {
        "key": "MimeType",
        "type": "StringType",
        "value": "text/html"
    },
    {
        "key": "OriginatingOrganization",
        "type": "StringType",
        "value": "North Systems"
    },
    {
        "key": "ItemTypeId",
        "type": "NumericalType",
        "value": 0
    },
    {
        "key": "ContentSource",
        "type": "StringType",
        "value": "Exchange Online"
    },
    {
        "key": "CreatedBy",
        "type": "StringType",
        "value": "Exchange Online Connector"
    },
    {
        "key": "CreatedDate",
        "type": "StringType",
        "value": "2021-12-23T19:21:40.0000000Z"
    },
    {
        "key": "ItemNumber",
        "type": "StringType",
        "value": "R0000004528"
    },
    {
        "key": "LastModifiedBy",
        "type": "StringType",
        "value": "dw@north.systems"
    },
    {
        "key": "LastModifiedDate",
        "type": "StringType",
        "value": "2022-02-04T19:50:30.0000000Z"
    },
    {
        "key": "NextDisposalAction",
        "type": "StringType",
        "value": "DestroyType"
    },
    {
        "key": "NextDisposalDate",
        "type": "StringType",
        "value": "2021-12-30T19:21:21.0000000Z"
    },
    {
        "key": "PreviousDisposalDate",
        "type": "StringType",
        "value": null
    },
    {
        "key": "PreviousDisposalAction",
        "type": "StringType",
        "value": null
    },
    {
        "key": "PreviousDisposalBy",
        "type": "StringType",
        "value": null
    },
    {
        "key": "Status",
        "type": "StringType",
        "value": "Managed"
    },
    {
        "key": "ConnectorDisplayName",
        "type": "StringType",
        "value": "Exchange Online Connector"
    },
    {
        "key": "VitalRecord",
        "type": "BooleanType",
        "value": false
    },
    {
        "key": "SecurityProfileIdentifier",
        "type": "StringType",
        "value": null
    },
    {
        "key": "UniqueExternalId",
        "type": "StringType",
        "value": "822371e2-89f8-4cdf-bdd6-43591ea2dfe5-ME3PR01MB8451B87F9DEA37CF85811E47EB7E9-ME3PR01MB8451.ausprd01.prod.outlook.com-.e08b4624-f7e6-4bdc-8a6f-a1806e4e200e"
    },
    {
        "key": "ClassificationType",
        "type": "NumericalType",
        "value": 4
    },
    {
        "key": "IsOnHold",
        "type": "BooleanType",
        "value": false
    },
    {
        "key": "LastExportedDate",
        "type": "StringType",
        "value": null
    },
    {
        "key": "LastExportedBy",
        "type": "StringType",
        "value": null
    },
    {
        "key": "LastExportedFormat",
        "type": "StringType",
        "value": null
    },
    {
        "key": "ConnectorId",
        "type": "StringType",
        "value": "e08b4624-f7e6-4bdc-8a6f-a1806e4e200e"
    },
    {
        "key": "DisposalApprovalStatus",
        "type": "StringType",
        "value": null
    },
    {
        "key": "Transition",
        "type": "StringType",
        "value": "None"
    },
    {
        "key": "SuggestedCategory",
        "type": "StringType",
        "value": "EML-01: Microsoft"
    },
    {
        "key": "SuggestedCategoryIdentifier",
        "type": "StringType",
        "value": "EML-01"
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|DateTime|Created",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|DateTime|Modified",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|DateTime|nsDocumentDate",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|Double|nsInvoiceValue",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|ContentTypeName",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|FileDirRef",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|FileRef",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|LibraryName",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|ListUrl",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|SiteName",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|SiteUrl",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|Title",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|WebUrl",
        "type": "StringType",
        "value": null
    },
    {
        "key": "PredictionProbability",
        "type": "NumericalType",
        "value": 0.624110895276128
    },
    {
        "key": "SentForDisposalApprovalDate",
        "type": "StringType",
        "value": null
    },
    {
        "key": "ItemSubTypeId",
        "type": "StringType",
        "value": null
    },
    {
        "key": "MlExperimentId",
        "type": "StringType",
        "value": "81320264-3379-11ec-8ad1-ea3f0992e784"
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|aluRecordClass",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|String|aluRecordClass (TermPath)",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|dad16653-9516-40fa-993a-d3d51706bb8d|DateTime|aluRecordEventDate",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|80283930-42e0-4c5a-b3a0-ce213951ce56|String|FileExtension",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|80283930-42e0-4c5a-b3a0-ce213951ce56|String|Author",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|80283930-42e0-4c5a-b3a0-ce213951ce56|String|Modified By",
        "type": "StringType",
        "value": null
    },
    {
        "key": "HoldId",
        "type": "StringType",
        "value": []
    },
    {
        "key": "S|424548d6-4d1a-4a7f-8879-05e067f47773|String|ProfileName",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|424548d6-4d1a-4a7f-8879-05e067f47773|DateTime|Date From",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|424548d6-4d1a-4a7f-8879-05e067f47773|DateTime|Date To",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|424548d6-4d1a-4a7f-8879-05e067f47773|String|Department",
        "type": "StringType",
        "value": null
    },
    {
        "key": "NapDeleteId",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|424548d6-4d1a-4a7f-8879-05e067f47773|DateTime|Record Trigger Date",
        "type": "StringType",
        "value": null
    },
    {
        "key": "S|424548d6-4d1a-4a7f-8879-05e067f47773|DateTime|Next Review Date",
        "type": "StringType",
        "value": null
    },
    {
        "key": "BinaryStateId",
        "type": "NumericalType",
        "value": 0
    },
    {
        "key": "groups",
        "type": "StringType",
        "value": []
    },
    {
        "key": "users",
        "type": "StringType",
        "value": []
    },
    {
        "key": "IconUrl",
        "type": "StringType",
        "value": "https://usw.records365.com/assets/img/exchangeonline colour icon.png"
    },
    {
        "key": "ConnectorIsCustom",
        "type": "BooleanType",
        "value": false
    }
]

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.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,579)