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 :
Dynamics 365 general forum

JavaScript error in updated UI page

(0) ShareShare
ReportReport
Posted on by 356

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:
I have the same question (0)
  • PaulM Profile Picture
    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?

  • Dhasara Devi G N Profile Picture
    356 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

  • Verified answer
    Linn Zaw Win Profile Picture
    3,407 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
    356 on at
    RE: JavaScript error in updated UI page

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

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 > Dynamics 365 general

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans