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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Xrm.WebApi not working in new UI v9

(0) ShareShare
ReportReport
Posted on by 967

Hi

Has anyone experienced any issues retrieving a record using Xrm.WebAp.retrieveRecord method in the new v9 Unified Interface?  I have created some JavaScript below that works fine in the classic web UI however when I use the new unified interface get errors in console 'A failure occurred in Wep Api in Dynamics 365'.  JavaScript example below:

function setSalesValue(executionContext)
{
 var formContext = executionContext.getFormContext();
 var daysDone = formContext.getAttribute("kit_daysdone").getValue();
 var salesValue = formContext.getAttribute("kit_salesvalue");
 
 Xrm.WebApi.retrieveRecord("kit_rates", "e85f60c6-1ec4-e811-a96b-0022480149c2", "?$select=kit_value").then(
  function success(result) {
   console.log(`Retrieved values: Value: ${result.kit_value}`);
   // perform operations on record retrieval
   var salesRateValue = result.kit_value;
   salesValue.setValue(daysDone * salesRateValue);
  },
  function (error) {
   console.log(error.message);
   // handle error conditions
  }
 );
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Xrm.WebApi not working in new UI v9

    We are using these Xrm.WebApi calls in UCI app without any issues. I would recommend you to open the same app in browser & debug it in developer toolbar for any weird behavior.

    Also in mobile app you can can debug by alerts using Xrm.Navigation.openAlertDialog

    docs.microsoft.com/.../openalertdialog

  • Suggested answer
    Arun Vinoth Profile Picture
    11,615 Moderator on at
    RE: Xrm.WebApi not working in new UI v9

    Can you try arrow function as you are trying to access formcontext control (salesValue) in success callback of promise.

    Xrm.WebApi.retrieveRecord("kit_rates", "e85f60c6-1ec4-e811-a96b-0022480149c2", "?$select=kit_value").then(

      result => {

      console.log(`Retrieved values: Value: ${result.kit_value}`);

      // perform operations on record retrieval

      var salesRateValue = result.kit_value;

      salesValue.setValue(daysDone * salesRateValue);

     },

     function (error) {

      console.log(error.message);

      // handle error conditions

     }

    );

  • Verified answer
    Sukh Gill Profile Picture
    967 on at
    RE: Xrm.WebApi not working in new UI v9

    Hi Arun

    Thanks for the response. I managed to resolve the issue as I was using the plural name for the entity and changing this worked.

    Thanks
    Sukh

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans