Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Sales forum / Javascript Errors on S...
Sales forum

Javascript Errors on Sales Hub (new interface UCI)

(0) ShareShare
ReportReport
Posted on by 1,846

Hi All,

Im getting a javascript error which runs fine on the old web interface but not on Sales Hub interface. The function runs on SAVE of form.

What can be the possible issue? Are some of the Javascript functions not supported for the new interface or any other reason?

Here is the code:

function GetGridValues()
{
    var rowData;
    var entity;
    var attribute;
    var sum=0;
    var i=0;
    var qty;
    var manual;
    manual = Xrm.Page.getAttribute("new_manuallyenterestrevenue").getValue();
    if(manual==0)
    {
   
         var filteredRecordCount = Xrm.Page.getControl("FeeEstimator").getGrid().getTotalRecordCount();
         for( i=0; i<filteredRecordCount ; i++)
         {
            rowData = Xrm.Page.getControl("FeeEstimator").getGrid().getRows().get(i).getData();
            entity = rowData.getEntity();   
            attribute = entity.getAttributes();      
            qty= attribute.get("new_totalsalesprice").getValue();
            sum=qty+sum;  
        }
        Xrm.Page.getAttribute("estimatedvalue").setValue(sum);
    }
}

Here is the error:

GetGridValues@test.crm4.dynamics.com/.../new_RoleAllocationTotal:18:29
DPXt/fo</e.prototype.executeFunction@test.crm4.dynamics.com/.../app.js
DPXt/fo</e.prototype.execute@test.crm4.dynamics.com/.../app.js
DPXt/co</e.prototype._executeIndividualEvent@test.crm4.dynamics.com/.../app.js
DPXt/co</e.prototype._executeEventHandler@test.crm4.dynamics.com/.../app.js
execute@test.crm4.dynamics.com/.../app.js
DPXt/wo</e.prototype._executeSyncAction@test.crm4.dynamics.com/.../app.js
DPXt/wo</e.prototype._executeSync@test.crm4.dynamics.com/.../app.js
DPXt/wo</e.prototype.executeAction@test.crm4.dynamics.com/.../app.js
Po/</</</t.dispatch@test.crm4.dynamics.com/.../app.js
boot/a</o</</n.dispatch</<@test.crm4.dynamics.com/.../app.js
dispatch@test.crm4.dynamics.com/.../app.js
dispatch@test.crm4.dynamics.com/.../app.js
et/</</</</<@test.crm4.dynamics.com/.../0.js
et/</</</<@test.crm4.dynamics.com/.../0.js

Categories:
  • Verified answer
    MNarmeen Profile Picture
    MNarmeen 1,846 on at
    RE: Javascript Errors on Sales Hub (new interface UCI)

    Hi thanks for the help everyone. This is how I managed to code

    function GetGridValues()

    {

    var rowData;

    var entity;

    var attribute;

    var sum=0;

    var i=0;

    var qty;

    var manual;

    Xrm.Page.getAttribute("estimatedvalue").setValue(0);

    manual = Xrm.Page.getAttribute("new_manuallyenterestrevenue").getValue();

    if(manual==0)

    {

    var filteredRecordCount = Xrm.Page.getControl("FeeEstimator").getGrid().getTotalRecordCount();

    for( i=0; i<filteredRecordCount ; i++)

    {

                   rowData = Xrm.Page.getControl("FeeEstimator").getGrid().getRows().get(i).getData();

                   entity = rowData.getEntity();  

                   attribute = entity.getAttributes();      

                   qty= attribute.get("new_totalsalesprice").getValue();

                   sum=qty+sum;  

    }

    Xrm.Page.getAttribute("estimatedvalue").setValue(sum);

    }

    }

    --------------------------------------------------------------------------------------------------------

                                              NEW JAVASCRIPT CODE

    --------------------------------------------------------------------------------------------------------

    function GetGridValues(executionContext)

    {

    var rowData;

    var feeentity;

    var attribute;

    var sum=0;

    var i=0;

    var qty=0;

    var formContext = executionContext.getFormContext();      

    var manual = formContext.getAttribute("new_manuallyenterestrevenue").getValue();

    var gridContext = formContext.getControl("FeeEstimator");

    var filteredRecordCount =gridContext.getGrid().getTotalRecordCount();

    if(!manual)

    {

      for( i=0; i<filteredRecordCount ; i++)

       {

          rowData = gridContext.getGrid().getRows().get(i).data;

          feeentity = rowData.entity;  

          qty = feeentity.attributes.get("new_totalsalesprice").getValue();      

           sum=qty+sum;  

         }

    }

    formContext.getAttribute("estimatedvalue").setValue(sum);

    }

  • Suggested answer
    Arun Vinoth Profile Picture
    Arun Vinoth 11,615 on at
    RE: Javascript Errors on Sales Hub (new interface UCI)

    We are in production with v9. Whole code is remediated for deprecated methods. Using UCI app as well. We are not facing any such issues. We worked closely with MS for any blockers & solved those problems.

    I would recommend you to check if legacy form rendering is still on in system settings.

    When you say you are getting this on save, can you debug (you can go deeper in F12 Developer toolbar) & see the exact line of error source?

    Share your crm version.

    If nothing works you can create a MS support ticket.

  • MNarmeen Profile Picture
    MNarmeen 1,846 on at
    RE: Javascript Errors on Sales Hub (new interface UCI)

    Dear Ben ,

    I wrote the following quote

    function GetGridValues(executionContext)
    {
        var formContext = executionContext.getFormContext(); // get formContext
    
        // use formContext instead of Xrm.Page  
        var topic = formContext.getAttribute("name").getValue(); 
        console.log(topic);
    }

    and enabled the check (pass executioncontext as first parameter) but still gives me the below error.
    What am i missing?

    Name is the default field name on opportunity form and im calling this OnSave of Opportunity form.

    @test.crm4.dynamics.com/.../ClientApiWrapper.aspx line 160 > eval:1:1
    RunHandlerInternal@test.crm4.dynamics.com/.../ClientApiWrapper.aspx
    RunHandlers@test.crm4.dynamics.com/.../ClientApiWrapper.aspx
    ExecuteHandler@test.crm4.dynamics.com/.../ClientApiWrapper.aspx
    $Dh_1@test.crm4.dynamics.com/.../formcontrols.js
    executeHandler@test.crm4.dynamics.com/.../formcontrols.js
    executeHandlerByDescriptor@test.crm4.dynamics.com/.../formcontrols.js
    getHandler/<@test.crm4.dynamics.com/.../formcontrols.js
    getHandler/<@test.crm4.dynamics.com/.../global.ashx
    $Et_1@test.crm4.dynamics.com/.../formcontrols.js
    $OX_1@test.crm4.dynamics.com/.../formcontrols.js
    saveInternal@test.crm4.dynamics.com/.../formcontrols.js
    save@test.crm4.dynamics.com/.../formcontrols.js
    save@test.crm4.dynamics.com/.../formcontrols.js
    $ND_1@test.crm4.dynamics.com/.../formcontrols.js
    Function.createDelegate/<@test.crm4.dynamics.com/.../MicrosoftAjax.js
    b@test.crm4.dynamics.com/.../MicrosoftAjax.js

  • Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: Javascript Errors on Sales Hub (new interface UCI)

    Javascript code using executioncontext has worked for me without any problems since I first started writing it back in October last year. And while I've been using it for all Javascript since last year I've not willingly worked on any unified interface systems as I didn't think it was suitable for production use...

  • MNarmeen Profile Picture
    MNarmeen 1,846 on at
    RE: Javascript Errors on Sales Hub (new interface UCI)

    So what if my client is using both the interfaces? Old web and Unified?

    How can I change the code depending on the interface?? Shouldn't it be uniform for all the interfaces?

    If I use replacement methods it will give me error on using old interface as well?

  • Suggested answer
    Ben Thompson Profile Picture
    Ben Thompson 6,350 on at
    RE: Javascript Errors on Sales Hub (new interface UCI)

    Xrm.Page is deprecated as on the Unified interface it's possible for multiple secondary forms (a grid row, quick form, related entity) to exist on the same page. While technically it seems that you've found a bug that should be fixed I suspect (given the deprecation) you are actually going to have to fix your code...

    https://docs.microsoft.com/en-us/dynamics365/get-started/whats-new/customer-engagement/important-changes-coming#some-client-apis-are-deprecated covers what the changes are and https://www.develop1.net/public/post/2017/11/11/executionContext-hits-the-big-time! has an explanation of what the changes look like and given that you are looking at gridrow data it may help you.. 

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... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans