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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Multiple unknown errors when I create or save opportunities (onload and onsave)

(0) ShareShare
ReportReport
Posted on by

Hello,

When creating and saving opportunities, I get two errors on events onsave on crmform and onload on field window, both are undefined, does someone know how to correct that?

Thanks

*This post is locked for comments

I have the same question (0)
  • Clem Profile Picture
    2,541 on at

    Do you have any more inputs to give us a lead ?

    Is it occuring on a trial org ? production org ?

    Is it occuring with a "brand new" form ?

    Clément

  • Community Member Profile Picture
    on at

    The problem is occurring on production org.

    It occurs when I create a new opportunity, or when I change the stage of an existing opportunity too quickly.

    In the second case, it seems to occur when the form is not completely loaded (for example : subgrids are loading) and I change the stage of the opportunity's Business process flow. I think the problem might be linked to workflows I created to perform some actions on the form.

  • Clem Profile Picture
    2,541 on at

    Try to deactivate those workflow.

    Try to create a new form and just create a new record with it, if no errors occur, then something's wrong with the one you are using.

    Are you using the Turbo Form engine ?

    It's hard to troubleshoot like that, so sorry if i can"t provide you real lead to the solution directly.

    Clément

  • Community Member Profile Picture
    on at

    I tried deactivating "legacy form rendering" in the systems setting and did the same actions, this time the error message was a little bit more explicit, but I'm not sure it is the same error :

    2772352.Capture.PNG

  • Clem Profile Picture
    2,541 on at

    Hello Vincent,

    Indeed more explicit, looks like you are calling a function "getData()" on an undefined variable in your custom function called "UpdateOffer" on the file rta_viewchildren line 46/53.

    Check there if you can debug.

    Or you can also paste your code to have a look.

  • Community Member Profile Picture
    on at

    I found the code, I'm not the one who wrote it, it was probably an intern before me..

    function UpdateOffer() {

       var grid = Xrm.Page.getControl("grid_offer");

       var oa = Xrm.Page.getAttribute("rta_loofferaccurency");

       var bd = Xrm.Page.getAttribute("rta_lobiddate");

       var vd = Xrm.Page.getAttribute("rta_lovaliditydate");

       var od = Xrm.Page.getAttribute("rta_loofferduration");

       var entite;

       if (grid == null) { //make sure the grid has loaded

           setTimeout(function () { UpdateOffer(); }, 2000); //if the grid hasn’t loaded run this again when it has

           return;

       }

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

       if (filteredRecordCount == 0) {

           return;

       } else if (filteredRecordCount == 1){

            entite =  grid.getGrid().getRows().get(0).getData().getEntity();

       }else{

            var prems = grid.getGrid().getRows().get(0).getData().getEntity().attributes.get("rta_date").getValue().split('/');

            var mon_poulain = new Date(prems[2],prems[1]-1,prems[0]);

            var lebonnum = 0;

            for( var i = 1; i < filteredRecordCount ;i++){

                    var parts = grid.getGrid().getRows().get(i).getData().getEntity().attributes.get("rta_date").getValue().split('/');

                    var mydate = new Date(parts[2],parts[1]-1,parts[0]);

                    if ( mon_poulain < mydate){ mon_poulain = mydate; lebonnum = i;}

            }

           entite =  grid.getGrid().getRows().get(lebonnum).getData().getEntity();

        }

            bd.setValue(entite.attributes.get("rta_date").getValue());

            od.setValue(entite.attributes.get("new_offerduration").getValue());

            var temp = entite.attributes.get("new_offeraccuracy").getValue();

            if (temp == "100000000"){

                   oa.setValue("Order of magnitude");

            }else if(temp == "100000001"){

                   oa.setValue("Budget");

            }else if(temp == "100000002"){

                    oa.setValue("Firm");

            }

            vd.setValue(entite.attributes.get("rta_validitydate").getValue());

    }

  • Suggested answer
    Clem Profile Picture
    2,541 on at

    just make sure that before you use the line : grid.getGrid().getRows().get(0).getData().whatever after that grid.getGrid().getRows() contains at least one row, otherwise the get(0) will return a null value and your script crash.

    Clément

  • Community Member Profile Picture
    on at

    isn't the point of the following lines to do that :

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

      if (filteredRecordCount == 0) {

          return;

      } else if (filteredRecordCount == 1){

           entite =  grid.getGrid().getRows().get(0).getData().getEntity();

      }else{

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Vincent ,

    I would suggest to retrieve data using WEB API instead of directly accessing from grid .

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans