Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Apply to each only seeing one item in my array

(0) ShareShare
ReportReport
Posted on by 146

Hi All

 

I've got a flow, part of which is a List Records CDS action - with my test data it is listing two records from my Quote entity (but it could be only one or could be several). I want to put two of the fields from each record (Service and Fee) into an HTML table and then put that into an email.

 

I've spent several hours playing around with it, and trying out things I've seen on other threads in this forum, but have now got stuck!

 

So far I've worked out that the output from my List Records action is an "object" but, to be useful for my purposes, needs to be an "array" - so I've initialised an array variable and have appended the List Records output to it. (I'll paste the full content of the array variable below).

 

I have then done an Apply to Each with a Select action (see screenshot below) to pull the Service ("_cr47b_service_value") and Fee ("cr47b_fee") fields from each "record" in the array.

 

However, the output I get from the Apply to Each action only includes the data from the first of the two records - I therefore think that the Apply to Each action is only seeing one "record" in the array.

 

Does anyone have any ideas as to how I can solve this?

 

Thanks!

 

Simon

 

Capture.PNG

 

[
{
"@odata.context": "https://uk-001.azure-apim.net/apim/commondataservice/?????????????????????????/$metadata#datasets('org5cc5ff1f.crm11')/tables('cr47b_quotes')/items",
"value": [
{
"@odata.id": "https://?????????.crm11.dynamics.com/api/data/v9.0/cr47b_quotes(4551f491-66b1-ea11-a812-000d3a0ae2f1)",
"@odata.etag": "",
"ItemInternalId": "4551f491-66b1-ea11-a812-000d3a0ae2f1",
"statecode": 1,
"_statecode_label": "Inactive",
"cr47b_instructedyesorno": true,
"createdon": "2020-06-18T13:21:17Z",
"_cr47b_service_value": "24c2f1e8-f09d-ea11-a812-000d3a0ae2f1",
"_cr47b_service_type": "cr47b_services",
"_cr47b_lead_value": "0518b9a6-a0b0-ea11-a812-000d3a0ae2f1",
"_cr47b_lead_type": "cr47b_leads",
"_ownerid_value": "8e2e3c48-f411-4356-b9dc-f2746f960bc4",
"_ownerid_type": "systemusers",
"modifiedon": "2020-06-20T09:16:55Z",
"versionnumber": 4191364,
"_cr47b_enquirercontact_value": "0318b9a6-a0b0-ea11-a812-000d3a0ae2f1",
"_cr47b_enquirercontact_type": "contacts",
"_transactioncurrencyid_value": "2147d59f-7992-ea11-a811-000d3a7f2195",
"_transactioncurrencyid_type": "transactioncurrencies",
"exchangerate": 1,
"statuscode": 446830003,
"_statuscode_label": "Instructed",
"cr47b_fee": 725,
"_modifiedby_value": "8e2e3c48-f411-4356-b9dc-f2746f960bc4",
"_modifiedby_type": "systemusers",
"cr47b_quoteref": "HBR-S 2 Biro Lane DT11 8JR",
"cr47b_quoteid": "4551f491-66b1-ea11-a812-000d3a0ae2f1",
"_createdby_value": "8e2e3c48-f411-4356-b9dc-f2746f960bc4",
"_createdby_type": "systemusers",
"_owningbusinessunit_value": "c1ac6071-6d92-ea11-a811-000d3a7f2195",
"_owningbusinessunit_type": "businessunits",
"cr47b_fee_base": 725
},
{
"@odata.id": "https://???????.crm11.dynamics.com/api/data/v9.0/cr47b_quotes(430ce255-73b1-ea11-a812-000d3a0ae2f1)",
"@odata.etag": "",
"ItemInternalId": "430ce255-73b1-ea11-a812-000d3a0ae2f1",
"statecode": 0,
"_statecode_label": "Active",
"createdon": "2020-06-18T14:52:32Z",
"_cr47b_service_value": "6da7dc07-f19d-ea11-a812-000d3a0ae2f1",
"_cr47b_service_type": "cr47b_services",
"_cr47b_lead_value": "0518b9a6-a0b0-ea11-a812-000d3a0ae2f1",
"_cr47b_lead_type": "cr47b_leads",
"_ownerid_value": "8e2e3c48-f411-4356-b9dc-f2746f960bc4",
"_ownerid_type": "systemusers",
"modifiedon": "2020-06-18T16:41:24Z",
"versionnumber": 3978907,
"_cr47b_enquirercontact_value": "0318b9a6-a0b0-ea11-a812-000d3a0ae2f1",
"_cr47b_enquirercontact_type": "contacts",
"_transactioncurrencyid_value": "2147d59f-7992-ea11-a811-000d3a7f2195",
"_transactioncurrencyid_type": "transactioncurrencies",
"exchangerate": 1,
"statuscode": 1,
"cr47b_fee": 450,
"_modifiedby_value": "8e2e3c48-f411-4356-b9dc-f2746f960bc4",
"_modifiedby_type": "systemusers",
"cr47b_quoteref": "HBR-SV 2 Biro Lane DT11 8JR",
"cr47b_quoteid": "430ce255-73b1-ea11-a812-000d3a0ae2f1",
"_createdby_value": "8e2e3c48-f411-4356-b9dc-f2746f960bc4",
"_createdby_type": "systemusers",
"_owningbusinessunit_value": "c1ac6071-6d92-ea11-a811-000d3a7f2195",
"_owningbusinessunit_type": "businessunits",
"cr47b_fee_base": 450
}
]
}
]
  • Verified answer
    v-bacao-msft Profile Picture
    on at
    Re: Apply to each only seeing one item in my array

     

    Hi @sdowse ,

     

    Please check this similar thread and see if it helps:

    How to collect information from different outputs ... - Power Platform Community

     

    Best Regards,

  • Verified answer
    Simon Dowse Profile Picture
    146 on at
    Re: Apply to each only seeing one item in my array

    Hi @Hardesh15 

     

    I think I've done it! I was creating the variable from the "body" of the List Records action output, but I noticed another option called "values" in the dynamic content - so I thought I'd try adding that to the array variable - but that didn't work, with the error saying that the "values" output is already an array.

     

    So I tried a Search action direct from the "values" of the List Records action and it found both the records. See screenshots below (the flow is a bit of a mess as I keep trying out different things!). All I need to do now is to use the Service ID to pull out the Service Name from its entity so my clients can see some sensible data in their emails!

     

    Thank you so much for your time and help.

     

    Simon

     

    Capture1.PNGCapture2.PNG

  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at
    Re: Apply to each only seeing one item in my array

    @sdowse 

     

    Pls share complete flow screens.

     

    Your select action has two records- [{},{}] see carefully

     

    Thanks

    Hardesh

  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at
    Re: Apply to each only seeing one item in my array

    @sdowse 

     

    In that case you variable has only one value and you are supplying this value as input in next Apply to each.

     

    Thanks

    Hardesh

     

  • Simon Dowse Profile Picture
    146 on at
    Re: Apply to each only seeing one item in my array

    Hi @Hardesh15 

     

    I've just been reading some of your posts on another thread!

     

    No, it wasn't in an apply to each - I had tried that previously but it just duplicated the text shown at the bottom of my original post - i.e. whole of the text appeared twice. Although in that case the Search action did pick up two "records", but the values returned were both the same as it was picking up the values from the first "record" in each of the two copies ("_cr47b_service_value": "24c2f1e8-f09d-ea11-a812-000d3a0ae2f1" and "cr47b_fee": 725.

  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at
    Re: Apply to each only seeing one item in my array

    @sdowse 

     

    When you did this-"appended the List Records output to it. (I'll paste the full content of the array variable below)." 

     

    is apply to each action used in appending?

     

    Thanks

    Hardesh

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >