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 :
Microsoft Dynamics CRM (Archived)

How to make Ajax Synchronous call in Dynamics 365 Portal.

(0) ShareShare
ReportReport
Posted on by 115

Hi All,

I have to get the records from an entity in synchronous mode and based on the output I have to do some set of operations in Portal entity form.

 Ásyn = false' is deprecated so the below code is not getting the result in synchronous mode. 

function getODataResponse(oDataUrl) {
var response = null;
$.ajax({
type: "GET",
url: oDataUrl,
async: false,
dataType: "json"
}).done(function (json) {
response = json.value;
});
return response;
}

Any suggestion please to read the data in sync mode from an entity in Dynamic 365 Portal.

Thanks & Regards,

Nandhini M

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Shaminderpal Singh Profile Picture
    1,565 on at

    Hi Nandhini,

    You can handle it using promises.

    var   serverRequest=function (url, httpVerb, data, isAsync, headers) {

                       var res = $.Deferred();

                       $.ajax({

                           type: httpVerb,

                           contentType: "application/json; charset=utf-8",

                           datatype: "json",

                           data: data !== null ? JSON.stringify(data) : data,

                           async: isAsync,

                           url: url,

                           beforeSend: function (XMLHttpRequest) {

                               XMLHttpRequest.setRequestHeader("Accept", "application/json");

                               if (headers) {

                                   $(headers).each(function (ind, elem) {

                                       XMLHttpRequest.setRequestHeader(elem.header, elem.value);

                                   });

                               }

                           },

                           complete: function (XmlHttpRequest) { },

                           success: function (data, textStatus, XmlHttpRequest) {

                               res.resolve(data);

                           },

                           error: function (data) {

                               res.reject(data);

                           }

                       });

                       return res.promise();

                   }

    then call this function like below:

    $.when(serverRequest('url','GET',null,true,null)).then((success)=>{

    //You will get your success response  here and write the code that you want to run after response here

    },(error)=>{

    //Error Handler

    })

    -Shaminder

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Hi,

    You should be able to make it run by changing false to true ?? have you already resolved if yes, you share share your steps so that it will help others as well. And make sure to close this thread.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans