web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / The result must be a v...
Power Automate
Unanswered

The result must be a valid array error

(0) ShareShare
ReportReport
Posted on by 388

 

Hi,

 

Created a flow to read the values from SQL table and then trying to execute another based on the values from previous action flow using for each loop action but I am getting the following error for for each action. 

 

The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Execute_spGetTerminatedEmp')?['resultsets']' is of type 'Object'. The result must be a valid array.

 

I used Parse JSON action but no luck.

 

Any suggestion to convert object into array?

Thank you

 

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    on at

    Hi , @aaedla 

    You need to pass the array to the "Apply to each" action. And you can not convert the Object to Array. You need to select the correct field from your "Execute_spGetTerminatedEmp" action.

    If this can not help you , can you share your "Execute_spGetTerminatedEmp" action's output in your flow run histroy?

     

    Best Regards,

    Yueyun Zhang

  • OK29 Profile Picture
    388 on at

    @v-yueyun-msft Thank you for your comments. I tried already but I got same error.

  • v-yueyun-msft Profile Picture
    on at

    Hi , @aaedla 

    Can you show your flow configuration in your side?

     

    Best Regards,

    Yueyun Zhang

  • OK29 Profile Picture
    388 on at

    Here is the flow actionsaaedla_0-1711333255725.png

     

  • v-yueyun-msft Profile Picture
    on at

    Hi , @aaedla 

    Can you show this action's output in your flow run histoty? And which data you want to loop in your side?

    vyueyunmsft_0-1711333520682.png

     

     

    Best Regards,

    Yueyun Zhang

  • OK29 Profile Picture
    388 on at

    @v-yueyun-msft  here is the sample output data. I would like to use Email.

     

    {
    "statusCode": 200,
    "headers": {
    "Cache-Control": "no-store, no-cache",
    "Pragma": "no-cache",
    "Transfer-Encoding": "chunked",
    "Vary": "Accept-Encoding",
    "Strict-Transport-Security": "max-age=31536000; includeSubDomains",
    "x-ms-request-id": "a7394be8-22ee-46ae-bf38-fe50a8a91b08",
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "DENY",
    "x-ms-connection-gateway-object-id": "48938ae0-851d-465d-9cb1-ae8f550396db",
    "Timing-Allow-Origin": "*",
    "x-ms-apihub-cached-response": "false",
    "x-ms-apihub-obo": "false",
    "Date": "Sun, 24 Mar 2024 03:59:25 GMT",
    "Content-Type": "application/json; charset=utf-8; odata.metadata=minimal",
    "Content-Length": "2440733",
    "Expires": "-1"
    },
    "body": {
    "ResultSets": {
    "Table1": [
    {
    "DisplayName": "LN, FN1",
    "Email": "UserFirstName1@xxx.com",
    "EmployeeNumber": "0000003",
    "AccountName": "XXXX",
    "Status": "T"
    },
    {
    DisplayName": "LN, FN2",
    "Email": "FN1_LN@xxx.com",
    "EmployeeNumber": "0000005",
    "AccountName": "XXXX",
    "Status": "T"
    },
    {
    DisplayName": "LN, FN2",
    "Email": "UserFirstName2@xxx.com",
    "EmployeeNumber": "0000007",
    "AccountName": "XXXX",
    "Status": "T"
    }

    ]
    },
    "OutputParameters": {}
    }
    }

  • Verified answer
    v-yueyun-msft Profile Picture
    on at

    Hi, @aaedla 

    You can use this code in your "Apply to each" action:
    body('Execute_spGetTerminatedEmp')?['ResultSets']?['Table1']

     

    Best Regards,

    Yueyun Zhang

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard