Skip to main content

Notifications

Dynamics 365 general forum

JavaScript error in updated UI page

Posted on by 354

Hi experts,

I have changed the system settings to use the new Unified Interface only option to 'yes'. I created a model-driven app and added existing account and appointment entities from the default solution. While testing these entities in the new UI, I get this errorUIError.png

Downloaded log file shows issue with below JavaScript function. Did anyone faced this issue and found solution?

I have a web resource in appointment entity and I call a function in on-load. 

function setAccountName(execContext){
var formContext = execContext.getFormContext();

if(formContext != null){
var roleId = formContext.getAttribute("regardingobjectid").getValue();
var accountId = formContext.getAttribute("new_accountid").getValue();

if(roleId != null && accountId == null){
roleId = roleId[0].id;
//var formType = formContext.ui.getFormType();

Xrm.WebApi.retrieveRecord("new_accountrole", roleId, "$select=_new_accountid_value")
.then(function(result) {
var accountid = result["_new_accountid_value"];
var accountname = result["_new_accountid_value@OData.Community.Display.V1.FormattedValue"];
var enttype = result["_new_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
//alert(accountname);
if(accountid != null){
formContext.getAttribute("new_accountid").setValue([{ id: accountid, name: accountname, entityType: enttype}]);
}
})
.fail(function(error) {
var message = error.message;
//Add handling of error that occurred
});
}
}
}

Categories:
  • Dhasara Devi G N Profile Picture
    Dhasara Devi G N 354 on at
    RE: JavaScript error in updated UI page

    thank you for the code and reference. This fixed the issue.

  • Verified answer
    Linn Zaw Win Profile Picture
    Linn Zaw Win 3,405 on at
    RE: JavaScript error in updated UI page
    [quote user="Dhasara Devi G N"]

    Xrm.WebApi.retrieveRecord("new_accountrole", roleId, "$select=_new_accountid_value")
    .then(function(result) {
    var accountid = result["_new_accountid_value"];

    [/quote]

    On the code above in Xrm.WebApi.retrieveRecord method call, the options parameter (3rd one) should start with "?"

    Correct code: Xrm.WebApi.retrieveRecord("new_accountrole", roleId, "?$select=_new_accountid_value")

    Ref: https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/xrm-webapi/retrieverecord

  • Dhasara Devi G N Profile Picture
    Dhasara Devi G N 354 on at
    RE: JavaScript error in updated UI page

    I did try and it shows error in files of CRM, not any custom page or script

  • xrmWiz Profile Picture
    xrmWiz 35 on at
    RE: JavaScript error in updated UI page

    Difficult to see where you are having the JavaScript issue, you may want to try and debug it in F12, and see if you can isolate?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans