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,...
Suggested Answer

Example of Get Method using safe ajax method in power pages

(0) ShareShare
ReportReport
Posted on by 15

I want to get the contact records using click of button in web page power portal

I have the same question (0)
  • Suggested answer
    Eiken Profile Picture
    on at

    Hi,

    Firstly add a custom button in the form using Js code.

    pastedimage1676616179089v1.png

    Then you can edit the Js code for the button and send ajax request.

    $(document).ready(function(){
    AddCloseButton();
    $('.btn-geyInf').bind('click',function(){
    var req = new XMLHttpRequest();
    req.open("GET", (Enter the interface here), true);
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200) {
    var results = JSON.parse(this.response);
    console.log(results.value);
    } else {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send();
    })
    });
    function AddCloseButton(){
    var button ="<input type='button' class='btn btn-geyInf' value='Get Contact Inf'/>"
    $("#EntityFormControl_862039e46daeed11aad1000d3a314363_EntityFormView").next().append(button);
    };


  • Suggested answer
    Eiken Profile Picture
    on at

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 171 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 83

#3
Jimmy Passeti Profile Picture

Jimmy Passeti 50 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans