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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Custom Activities Javascript integration

(0) ShareShare
ReportReport
Posted on by 3

Hello, I'm a junior developer, and I'm trying to implement a functionality that aims to utilize user interactions with the website. For instance, if the user clicks on a specific product on the webpage, I want to trigger an activity in Dynamics that states /this user is interested in product X/. Is there a way to create something like this in Dynamics using JavaScript?
I have the same question (0)
  • Verified answer
    Dengliang Li Profile Picture
    Microsoft Employee on at
    Hi,
     
    You can send an XMLHTTPRequest to Powre Automate Flow by clicking on a specific product.
    A JSON string containing the product information is included in the sent request.
    Then create an activity in Power Automate Flow using the product information.
     
    In my testing, the flow is triggered when Product 1 is clicked.
    The source code is shown below.
     
    <div id="prodcut" style="height: 100px;width: 100px;border: 1px solid;">
            <p>Product1</p>
            <p>Product2</p>
            <p>Product3</p>
        </div>
    <script>
     
       var product =document.getElementsByTagName("p")[0];
       product.addEventListener("click",function(e){
            let data={"Product_Name":""};
           
            //Get the name of the product
            data.Product_Name = e.target.innerHTML;
            // This URL comes from the connector in the flow / when an HTTP request is received / generated URL.
            var  requrl = "<Your URL>"
            var req = new XMLHttpRequest();
            req.open("POST",requrl,true);
            req.setRequestHeader("Accept","application/json");
            req.setRequestHeader("OData-MaxVersion","4.0");
            req.setRequestHeader("OData-Version","4.0");
            req.setRequestHeader("If-None-Match","null");
            req.setRequestHeader("Content-Type","application/json ");
            req.send(JSON.stringify(data));
    </script>
     
    The Power Automate Flow is shown below.
    The HTTP POST URL is the request URL in the above code.
     
    Below are the links that can be referenced.
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.
    If you have further 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 96 Super User 2025 Season 2

#2
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans