locked
Have the form names changes in CRM 2011? RRS feed

  • Question

  • I just converted our CRM from 4.0 online to 2011 online and then ran the Javascript converter tool on my javascript. However, I continue to get the error shown here and I'm wondering if some form names have changed. I've also included the javascript which is causing the error. Any input would be great.
     
    //SV-->
    crmForm.all.transactioncurrencyid_c.style.visibility = 'hidden';
    crmForm.all.transactioncurrencyid_d.style.visibility = 'hidden';
    
    crmForm.all.isrevenuesystemcalculated_c.style.visibility = 'hidden';
    crmForm.all.isrevenuesystemcalculated_d.style.visibility = 'hidden';
    
    
    
    Xrm.Page.getControl("tab4T").setVisible(false);
    //crmForm.all.tab4Tab.style.position = "absolute";
    
    
    Xrm.Page.getAttribute("new_units").setSubmitMode("always");
    
    
    SetAnnualDues = function() {
    
      if (Xrm.Page.getAttribute("new_annualdues").getValue() != null)
        Xrm.Page.getAttribute("new_annualdues").setValue(Xrm.Page.getAttribute("new_noofagents").getValue() * 390);
      else
        Xrm.Page.getAttribute("new_annualdues").setValue(0);
    }
    SetAnnualDues(); //add this on the on change event of the noofagents as well
    Xrm.Page.getAttribute("new_annualdues").setSubmitMode("always");
    Xrm.Page.getControl("new_annualdues").setDisabled(true);
    
    SetEstimatedRevenue = function() {
      Xrm.Page.getControl("estimatedvalue").setDisabled(false);
      var oldVal = Xrm.Page.getAttribute("estimatedvalue").getValue();
      var newVal = 0;
    
      SetAnnualDues();
      var vals = Xrm.Page.getAttribute("new_adfund").getValue() +
            Xrm.Page.getAttribute("new_annualdues").getValue() +
            Xrm.Page.getAttribute("new_continuingfee").getValue();
    
    
      switch (Xrm.Page.getAttribute("new_franchisefee").getValue()) {
        case '1':
          newVal = 14000;
          break;
        case '2':
          newVal = 20000;
          break;
        case '3':
          newVal = 28000;
          break;
        case '4':
          newVal = 5000;
          break;
         case '5':
          newVal = 12500;
          break;
         case '6':
          newVal = 10000;
          break;
        default:
          newVal = 0;
          break;
      }
    //  if (newVal != oldVal || oldVal == null) {
    
        if (Xrm.Page.getAttribute("new_noofoffices").getValue() > 0){
          Xrm.Page.getAttribute("estimatedvalue").setValue(newVal * Xrm.Page.getAttribute("new_noofoffices").getValue());
        }
        else{
         Xrm.Page.getAttribute("estimatedvalue").setValue(newVal);
        }
    
       Xrm.Page.getAttribute("estimatedvalue").setSubmitMode("always");
    //  }
      Xrm.Page.getControl("estimatedvalue").setDisabled(true);
    }
    SetEstimatedRevenue();
    
    SetOpportunityTypeReqs = function() {
      if (Xrm.Page.getAttribute("new_opportunitytype").getValue() == 1 || Xrm.Page.getAttribute("new_opportunitytype").getValue() == 3) {
        Xrm.Page.getAttribute("new_noofagents").setRequiredLevel("required");
        Xrm.Page.getAttribute("new_noofoffices").setRequiredLevel("required");
        Xrm.Page.getAttribute("new_companyname").setRequiredLevel("required");
      }
      else {
        Xrm.Page.getAttribute("new_noofagents").setRequiredLevel("none");
        Xrm.Page.getAttribute("new_noofoffices").setRequiredLevel("none");
        Xrm.Page.getAttribute("new_companyname").setRequiredLevel("none");
      }
    }
    SetOpportunityTypeReqs();
    
    
    crmForm.all.pricelevelid_c.style.visibility = 'hidden';
    crmForm.all.pricelevelid_d.style.visibility = 'hidden';
    
    crmForm.all.customerid.setAttribute("lookuptypes", "2");
    
    
    
    SetOppType = function() {
      if (Xrm.Page.getAttribute("new_opportunitytype").getValue() == 3) {
        crmForm.all.new_company2_c.style.visibility = 'visible';
        crmForm.all.new_company2_d.style.visibility = 'visible';
        crmForm.all.new_company3_c.style.visibility = 'visible';
        crmForm.all.new_company3_d.style.visibility = 'visible';
        crmForm.all.new_company4_c.style.visibility = 'visible';
        crmForm.all.new_company4_d.style.visibility = 'visible';
        crmForm.all.new_company5_c.style.visibility = 'visible';
        crmForm.all.new_company5_d.style.visibility = 'visible';
      }
      else {
        crmForm.all.new_company2_c.style.visibility = 'hidden';
        crmForm.all.new_company2_d.style.visibility = 'hidden';
        crmForm.all.new_company3_c.style.visibility = 'hidden';
        crmForm.all.new_company3_d.style.visibility = 'hidden';
        crmForm.all.new_company4_c.style.visibility = 'hidden';
        crmForm.all.new_company4_d.style.visibility = 'hidden';
        crmForm.all.new_company5_c.style.visibility = 'hidden';
        crmForm.all.new_company5_d.style.visibility = 'hidden';
      }
    }
    SetOppType(); // also add this in the change event of new_opportunitytype
    
    
    
    
    
    _SetSalesStage = function(Section, Disabled) {
      var i;
      for (i = 0; i < Section.all.length; i++) {
        Section.all[i].Disabled = Disabled;
      }
    }
    
    
    var DayDiff = function(d2, d1) {
      if (d2 == null || d1 == null) return null;
      var t2 = d2.getTime();
      var t1 = d1.getTime();
      return Math.abs(parseInt((t2 - t1) / (24 * 3600 * 1000)));
    }
    
    
    SetSalesStage = function() {
      _SetSalesStage(crmForm.all.new_bdccompletedafacetofacemeeting_c.parentElement.parentElement.parentElement, true); //disable stage 2
      _SetSalesStage(crmForm.all.new_fddapplicationkitprovided_c.parentElement.parentElement.parentElement, true); //disable stage 3
      _SetSalesStage(crmForm.all.new_officevalidationvisitcompleted_c.parentElement.parentElement.parentElement, true); //disable stage 4
      _SetSalesStage(crmForm.all.new_applicationpickupcomplete_c.parentElement.parentElement.parentElement, true); //disable stage 5
      _SetSalesStage(crmForm.all.new_candidatesignsagreement_c.parentElement.parentElement.parentElement, true); //disable stage 6
      Xrm.Page.getAttribute("new_salesstage").setValue('1');
      Xrm.Page.getAttribute("new_salesstage").setSubmitMode("always");
    
    
    
      var createdDate = Xrm.Page.getAttribute("createdon").getValue();
      if (createdDate == null) createdDate = new Date();
    
      if (Xrm.Page.getAttribute("new_bdccompletedinitialcontact").getValue() != null && Xrm.Page.getAttribute("new_bdcschedulemeetingwithcandidate").getValue() != null) {
        Xrm.Page.getAttribute("new_salesstage").setValue('2');
        _SetSalesStage(crmForm.all.new_bdccompletedafacetofacemeeting_c.parentElement.parentElement.parentElement, false); //enable stage 2    
    
        //Set days in stage if the date field(s) was changed
        if (crmForm.all.new_bdccompletedinitialcontact.IsDirty != false || crmForm.all.new_bdcschedulemeetingwithcandidate.IsDirty != false) {
          Xrm.Page.getAttribute("new_stage1completedon").setValue(new Date());
          Xrm.Page.getAttribute("new_days_1to2").setValue(DayDiff(createdDate, Xrm.Page.getAttribute("new_stage1completedon").getValue()));
        }
      }
      else {
        Xrm.Page.getAttribute("new_stage1completedon").setValue(null);
        Xrm.Page.getAttribute("new_days_1to2").setValue(null);
        return;
      }
    
      if (Xrm.Page.getAttribute("new_bdccompletedafacetofacemeeting").getValue() != null && Xrm.Page.getAttribute("new_bdcscheduledmeeting").getValue() != null) {
        Xrm.Page.getAttribute("new_salesstage").setValue('3');
        _SetSalesStage(crmForm.all.new_fddapplicationkitprovided_c.parentElement.parentElement.parentElement, false); //enable stage 3
    
        //Set days in stage if the date field(s) was changed
        if (crmForm.all.new_bdccompletedafacetofacemeeting.IsDirty != false || crmForm.all.new_bdcscheduledmeeting.IsDirty != false) {
          Xrm.Page.getAttribute("new_stage2completedon").setValue(new Date());
          Xrm.Page.getAttribute("new_days_2to3").setValue(DayDiff(Xrm.Page.getAttribute("new_stage2completedon").getValue(), Xrm.Page.getAttribute("new_stage1completedon").getValue()));
        }
      }
      else {
        Xrm.Page.getAttribute("new_stage2completedon").setValue(null);
        Xrm.Page.getAttribute("new_days_2to3").setValue(null);
        return;
      }
    
      if (Xrm.Page.getAttribute("new_fddapplicationkitprovided").getValue() != null && Xrm.Page.getAttribute("new_onsitepresentationcomplete").getValue() != null
        && Xrm.Page.getAttribute("opportunityratingcode").getValue() != null) {
        Xrm.Page.getAttribute("new_salesstage").setValue('4');
        _SetSalesStage(crmForm.all.new_officevalidationvisitcompleted_c.parentElement.parentElement.parentElement, false); //enable stage 4
    
        if (crmForm.all.new_fddapplicationkitprovided.IsDirty != false || crmForm.all.new_onsitepresentationcomplete.IsDirty != false
        || crmForm.all.opportunityratingcode.IsDirty != false) {
          Xrm.Page.getAttribute("new_stage3completedon").setValue(new Date());
          Xrm.Page.getAttribute("new_days_3to4").setValue(DayDiff(Xrm.Page.getAttribute("new_stage3completedon").getValue(), Xrm.Page.getAttribute("new_stage2completedon").getValue()));
        }
      }
      else {
        Xrm.Page.getAttribute("new_stage3completedon").setValue(null);
        Xrm.Page.getAttribute("new_days_3to4").setValue(null);
        return;
      }
    
      if (Xrm.Page.getAttribute("new_officevalidationvisitcompleted").getValue() != null) {
        Xrm.Page.getAttribute("new_salesstage").setValue('5');
        _SetSalesStage(crmForm.all.new_applicationpickupcomplete_c.parentElement.parentElement.parentElement, false); //enable stage 5
    
        if (crmForm.all.new_officevalidationvisitcompleted.IsDirty != false) {
          Xrm.Page.getAttribute("new_stage4completedon").setValue(new Date());
          Xrm.Page.getAttribute("new_days_4to5").setValue(DayDiff(Xrm.Page.getAttribute("new_stage4completedon").getValue(), Xrm.Page.getAttribute("new_stage3completedon").getValue()));
        }
    
      }
      else {
        Xrm.Page.getAttribute("new_stage4completedon").setValue(null);
        Xrm.Page.getAttribute("new_days_4to5").setValue(null);
        return;
      }
    
      if (Xrm.Page.getAttribute("new_applicationpickupcomplete").getValue() != null && Xrm.Page.getAttribute("new_applicationkitsenttovpofsales").getValue() != null
        && Xrm.Page.getAttribute("new_regionaldirectormeeting").getValue() != null) {
        Xrm.Page.getAttribute("new_salesstage").setValue('6');
        _SetSalesStage(crmForm.all.new_candidatesignsagreement_c.parentElement.parentElement.parentElement, false); //enable stage 6
    
        if (crmForm.all.new_applicationpickupcomplete.IsDirty != false || crmForm.all.new_applicationkitsenttovpofsales.IsDirty != false ||
         crmForm.all.new_regionaldirectormeeting.IsDirty != false) {
          Xrm.Page.getAttribute("new_stage5completedon").setValue(new Date());
          Xrm.Page.getAttribute("new_days_5to6").setValue(DayDiff(Xrm.Page.getAttribute("new_stage5completedon").getValue(), Xrm.Page.getAttribute("new_stage4completedon").getValue()));
        }
      }
      else {
        Xrm.Page.getAttribute("new_stage5completedon").setValue(null);
        Xrm.Page.getAttribute("new_days_5to6").setValue(null);
        return;
      }
    
      if (Xrm.Page.getAttribute("new_candidatesignsagreement").getValue() != null && Xrm.Page.getAttribute("new_paymentreceived").getValue() != null) {
        Xrm.Page.getAttribute("new_salesstage").setValue('7');
    
        if (crmForm.all.new_candidatesignsagreement.IsDirty != false || crmForm.all.new_paymentreceived.IsDirty != false) {
          Xrm.Page.getAttribute("new_stage6completedon").setValue(new Date());
          Xrm.Page.getAttribute("new_days_6toclose").setValue(DayDiff(Xrm.Page.getAttribute("new_stage6completedon").getValue(), Xrm.Page.getAttribute("new_stage5completedon").getValue()));
          Xrm.Page.getAttribute("new_days_1toclose").setValue(DayDiff(createdDate, Xrm.Page.getAttribute("new_stage1completedon").getValue()));
        }
      }
      else {
        Xrm.Page.getAttribute("new_stage6completedon").setValue(null);
        Xrm.Page.getAttribute("new_days_6toclose").setValue(null);
        Xrm.Page.getAttribute("new_days_1toclose").setValue(null);
        return;
      }
    
    }
    SetSalesStage(); //also add this in the event change of all stage dates, new_regionaldirectormeeting and opportunityratingcode
    
    
    SetUnits = function() {
      if (Xrm.Page.getAttribute("new_opportunitytype").getValue() == '2' ||
          Xrm.Page.getAttribute("new_opportunitytype").getValue() == '3' ||
          Xrm.Page.getAttribute("new_opportunitytype").getValue() == '4')
        Xrm.Page.getAttribute("new_units").setValue(1);
      else if (Xrm.Page.getAttribute("new_opportunitytype").getValue() == '1')
        Xrm.Page.getAttribute("new_units").setValue(Xrm.Page.getAttribute("new_noofoffices").getValue());
    }
    SetUnits(); //Add this in the opportunity type change event as well.
    
    
    Xrm.Page.getControl("new_agentestimatedrevenue").setDisabled(true);
    SetAgentEstRevenue = function() {
    
      var Adfund = Xrm.Page.getAttribute("new_adfund").getValue();
      var Continuing = Xrm.Page.getAttribute("new_continuingfee").getValue();
      var AnnualDues = Xrm.Page.getAttribute("new_annualdues").getValue();
      var NoOfAgents = Xrm.Page.getAttribute("new_noofagents").getValue();
      if (Adfund == null) Adfund = 0;
      if (Continuing == null) Continuing = 0;
      if (AnnualDues == null) AnnualDues = 0;
      if (NoOfAgents == null) NoOfAgents = 1;
    
      var AgentEstRevenue = (Adfund * NoOfAgents * 12) + (Continuing * NoOfAgents * 12) + AnnualDues;
      if (AgentEstRevenue != Xrm.Page.getAttribute("new_agentestimatedrevenue").getValue()) {
        Xrm.Page.getAttribute("new_agentestimatedrevenue").setValue(AgentEstRevenue);
        Xrm.Page.getAttribute("new_agentestimatedrevenue").setSubmitMode("always");
      }
    }
    SetAgentEstRevenue(); //also add this to the change event of Adfund,Continuing and AnnualDues
    
    
    //<--SV
    
    //REM
    
    document.getElementById("navQuotes").style.display = "none";
    document.getElementById("navOrders").style.display = "none";
    document.getElementById("navInvoices").style.display = "none";
    //document.getElementById("navAsyncOperations").style.display = "none";
    
    //REM


     

     


    Maria
    Friday, August 19, 2011 9:19 PM

Answers

  • Hi,

    Try change the following code line:

    From

    Xrm.Page.getControl("tab4T").setVisible(false);

    To

    if (Xrm.Page.ui.tabs.get("tab4T") != null)
    

    {

        Xrm.Page.ui.tabs.get("tab4T").setVisible(false);

    }


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Jehanzeb.Javeed Saturday, August 20, 2011 12:34 AM
    • Marked as answer by mg1124 Thursday, August 25, 2011 4:20 PM
    Saturday, August 20, 2011 12:33 AM

All replies

  • Hi,

    Use Internet Explorer developer tools (F12) (download here http://www.microsoft.com/download/en/details.aspx?id=18359) to debug the line(s) that's causing the problem.

    on quick inspection, you have script that shows/hides tabs/sections that should be converted to the new 2011 sdk model (download the crm201sdk for guidlines) and you're also using script to hide navigation items that no longer needs to be there (can customize via the form designer).

    Hope that gets you started,

    Rob


    Microsoft Certified Technology Specialist (CRM) GAP Consulting Ltd Microsoft Community Contributor Award 2011
    Friday, August 19, 2011 9:59 PM
    Answerer
  • Hi,

    Try change the following code line:

    From

    Xrm.Page.getControl("tab4T").setVisible(false);

    To

    if (Xrm.Page.ui.tabs.get("tab4T") != null)
    

    {

        Xrm.Page.ui.tabs.get("tab4T").setVisible(false);

    }


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Jehanzeb.Javeed Saturday, August 20, 2011 12:34 AM
    • Marked as answer by mg1124 Thursday, August 25, 2011 4:20 PM
    Saturday, August 20, 2011 12:33 AM