Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Answered

How to Pass an array from JavaScript to PowerAtomate?

Posted on by 379
Hi,
 
I have a requirement, like I have a sub-grid on custom Entity, on that sub-grid I need to add a download button, on click of that button I want to run an Ms flow.
 
Where I need to pass an array of selected records id from the sub-grid and I want to get these id's inside the power automate to achieve my further requirements.
 
But I am not able to trigger the Ms flow on click of button.
 
Here I have attached two SS below, where I have written the JS code to run a Ms Flow and second for Ms flow /Json Schema/ to get the array of id's.
 
Js Code to run the MS flow:
 
 
My Array After Converting into JSON String:
 
[{/Id/:/12348/,/Name/:/Test1/,/TypeName/:/new_abc/,/TypeCode/:333444}
,{/Id/:/4567/,/Name/:/Test2/,/TypeName/:/new_efg/,/TypeCode/:35678}]
 
MS Flow JSON Schema:
 
 
JSON Schema Code:
 
{
    /type//array/,
    /items/: {
        /type//object/,
        /properties/: {
            /Id/: {
                /type//string/
            },
            /Name/: {
                /type//string/
            },
            /TypeName/: {
                /type//string/
            },
            /TypeCode/: {
                /type//integer/
            }
        },
        /required/: [
            /Id/,
            /Name/,
            /TypeName/,
            /TypeCode/
        ]
    }
}
  • Himanshu Kamboj Profile Picture
    Himanshu Kamboj 379 on at
    How to Pass an array from JavaScript to PowerAtomate?
    yes,
     
    I had initialized the XMLHttpRequest instance object globally, but now I have added all request headers as per the link provide by you and now my Ms flow getting triggered.
     
    Thanks for the solution!!
  • Verified answer
    Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    How to Pass an array from JavaScript to PowerAtomate?
    Hi,

    I don't see in your code the step of creating the XMLHttpRequest instance object, which is required to send the request.
    I found an article about running Microsoft Flow through Custom Ribbon Button using http request, please refer to this article.
    https://www.inogic.com/blog/2019/10/how-to-run-microsoft-flow-through-custom-ribbon-button-using-http-request/

     I hope my answer is helpful to you! If you have any other questions, please feel free to contact me.
     
    Best Regards,
    Dengliang Li

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans