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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

why I am not getting value in result what's wrong with the code

(0) ShareShare
ReportReport
Posted on by 365
function onformload(executioncontext){
    debugger    
var req = new XMLHttpRequest();
var id = Xrm.Page.data.entity.getId();
var results;
req.open("GET"Xrm.Page.context.getClientUrl() + "/api/data/v9.1/ap_pensionss?$select=ap_fundsrequestedfromcedingscheme,ap_fundsreceviedfromceedingschemedate&$filter=ap_opportunitypensionsid eq "id.replace("{""").replace("}""") ,false);
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) {
    debugger;
results = JSON.parse(this.response);
debugger;

else {
}
}
};
req.send();
}
I have the same question (0)
  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hi,

    I would recommend to install Rest Builder solution on your crm instance to Auto generate web api code and test it inside the same tool.

    Download link - github.com/.../releases

    Another option is to use Xrm.Webapi instead of xmlhttprequest.

    docs.microsoft.com/.../retrieverecord

    Replace your filter with below

    &$filter=ap_opportunitypensionsid eq '"id.replace("{""").replace("}"'

    Please mark my answer verified if i were helpful

  • unbeatable Profile Picture
    365 on at

    this not help full at all

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi partner,

    Could you use Rest Builder to create request?

    You can refer following screenshot to create request.

    pastedimage1601277254027v1.png

    pastedimage1601277523019v1.png

    Then you can use it in combination with the code below and the code in the image above.

    function test(executionContext) {
    
        var formContext = executionContext.getFormContext();
        var id = formContext.data.entity.getId();
    id = id.replace("{", "").replace("}", "");
    var req = new XMLHttpRequest();
    req.open("GET", Xrm.Page.context.getClientUrl()   "/api/data/v9.1/contacts?$select=_accountid_value,address1_addressid,emailaddress1,fullname&$filter=_accountid_value eq " id "", true);
    ……
    

    And you can try to use asynchronous requests, because synchronous requests block the execution of code which causes "freezing" on the screen and an unresponsive user experience.

    This means that you need change ‘false’ with ‘true’.

    pastedimage1601277411575v3.png

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 166

#2
ManoVerse Profile Picture

ManoVerse 149 Super User 2026 Season 1

#3
Zhilan Profile Picture

Zhilan 55

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans