Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Xrm.WebApi not working in new UI v9

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

  • Verified answer
    Sukh Gill Profile Picture
    Sukh Gill 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

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 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

     }

    );

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,613 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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans