Articles

Affichage des articles du octobre, 2019

CRM dynamics V9 wait Async web API to contiue code

hello

here is how to do an async call from v9


here is the structur of a call


function azerty ()
{
  Xrm.WebApi.retrieveMultipleRecords("teams", "?$select=name,teamid&$filter="+clause).then(
      function success(result)
        {
    //Your COde here part A
        },

        function (error)
        {
            Xrm.Navigation.openAlertDialog(error.message);
        }
    );


 //other code here; part b //Yuou want this code to be executed after part A
because the webapi call is assync the part B would be executed before part A

}

then if you want to execute part B after part A here is how to do
In green what is change to make it work

async function azerty ()
{
//Some code

await myPartAcode();

partBcode;


}

function myPartAcode()
{

return new Promise(resolve => { {
resolve(



  Xrm.WebApi.retrieveMultipleRecords("teams", "?$select=name,teamid&$filter="+clause).then(
      function success(result)
        {
            // perform operations on…