locked
Onload not firing RRS feed

  • Question

  • We have Onload code in Quote that runs when you create a quote from the main page.  When I create from an Opportunity, the code does not fire.  Also not working from Outlook Client.  Any ideas?

    Ken


    Ken Compter
    Saturday, October 2, 2010 6:47 PM

Answers

  • Hi, Ken.

     

    Actually it doesn't work because of following lines

    var CRM_FORM_TYPE_CREATE = 1; if (crmForm.FormType==CRM_FORM_TYPE_CREATE)

     

    When you click new from opportunity window - opened quote is already saved to DB. To make your script work you should use following code:

    if (crmForm.FormType==1 || crmForm.FormType == 2)

    {

    //Here is your logic

    }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by HIMBAPModerator Sunday, October 3, 2010 2:53 PM
    • Marked as answer by kcompter Monday, October 4, 2010 11:51 AM
    Sunday, October 3, 2010 2:12 PM
    Moderator

All replies

  • Hello, Ken.

     

    Can you publish your code here?


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Sunday, October 3, 2010 8:57 AM
    Moderator
  • Here is the code:

    /* Retext/Rename Left Nav Display links. */
    function leftNavRename(leftNav, oldName, newName)
    {
        var navItem = document.getElementById(leftNav);
        if(navItem  != null)
        {
            navItem.innerHTML = navItem.innerHTML.replace(oldName, newName);
            navItem.innerHTML = navItem.innerHTML.replace(oldName, newName);
        }
    }
    leftNavRename ('navWriteInProducts','Write-In Products','Skylights');

    ///Rename New Quote Product Button
    reNameAddNewProductButton = function p()
    {
    var navElement = document.getElementById('navWriteInProducts');
    if (navElement != null)
    {
    navElement.onclick = function LoadAreaOverride()
    {
    // Call the original method to launch the navigation link
    loadArea('areaWriteInProducts');

    var associatedViewIFrame = document.getElementById('areaWriteInProducts'+ 'Frame');
    if (associatedViewIFrame != null)
    {
    associatedViewIFrame.onreadystatechange = function ChangeTitledButton()
    {
    if (associatedViewIFrame.readyState == 'complete')
    {
    var iFrame = frames[window.event.srcElement.id];
    var liElements = iFrame.document.getElementsByTagName('li');
    for (var i = 0; i < liElements.length; i++)
    {
    if (liElements[i].getAttribute('title') == 'Add a new Quote Product to this record')
    {
    liElements[i].innerHTML = liElements[i].innerHTML.replace("New Quote Product","New Skylight");
    liElements[i].innerHTML = liElements[i].innerHTML.replace("New Quote Product","New Skylight");
    }
    }
    }
    }
    }
    }
    }
    }
    reNameAddNewProductButton();

    ////Hide Navigation Bar items

    if (document.getElementById('navExistingProducts') != null) document.getElementById('navExistingProducts').style.display = 'none';

    //Hide Hidden Tab
    crmForm.all.tab5Tab.style.display = 'none';

    ///Default Price List
    if ((crmForm.all.pricelevelid != null) &&
    (crmForm.all.pricelevelid.DataValue == null))
    {
        var lookupItem = new Array();
     
        /* Values on the signature of LookupControlItem are: GUID of pricelevel,
        type code of pricelevel and finally the name of the lookup value */
        lookupItem[0] = new LookupControlItem ('{6CF8F00D-A1AB-DF11-8304-00155D7F7F04}', 1022,  'Commercial');
     
        crmForm.all.pricelevelid.DataValue = lookupItem;
    }

    //Pre-populate fields
    var CRM_FORM_TYPE_CREATE = 1;

    if (crmForm.FormType==CRM_FORM_TYPE_CREATE)
    {
    crmForm.all.synact_acurlitestructuralskylightsto.DataValue = 'Design, Engineer, Fabricate, Deliver & Install';
    crmForm.all.synact_shopdrawingsforapproval.DataValue = '(3 Sets Included)';
    crmForm.all.synact_proposalspreparedfrom2.DataValue ='Plans & Specifications provided.';
    crmForm.all.synact_designloads.DataValue='Ground snow loads assumed; not specified at the time of the proposal.';
    crmForm.all.synact_deflectionlimited.DataValue='The maximum allowable deflection of any framing member normal to the plane of the glass shall not exceed L/175. For spans 20ft-0in or greater the maximum allowable deflection shall not exceed L/240.';
    crmForm.all.synact_proposalutilizes.DataValue='ACURLITE Standard Shapes, Profiles & Designs.';
    crmForm.all.synact_producttesting.DataValue='Standard Product Testing Data Provided.';
    crmForm.all.synact_glasssealfailurewarranty.DataValue='10-year seal failure, breakage not included, 5 years delimation.';
    crmForm.all.synact_shopdrawingleadtime.DataValue='+/- 1 to 2 weeks';
    crmForm.all.synact_materialshipment.DataValue='6 to 8 weeks after approved shop drawings, consult factory for current lead times.';
    crmForm.all.synact_sellingadvantage1.DataValue='Above quoted skylight to have insulated flashings. Insulated flashings to consist of .040 aluminum/1in. Rigid Foam/.040 aluminum. ';
    crmForm.all.synact_sellingadvantage2.DataValue='Above quoted skylight to have insulated flashings. Insulated flashings to consist of .040 aluminum/1in. Rigid Foam/.060 aluminum. ';
    crmForm.all.synact_sellingadvantage3.DataValue='Above quoted skylight to ship via company vehicle or dedicated carrier. Unit will ship construction ready (K/D), partially assembled as shipping restrictions allow.  ';
    crmForm.all.synact_sellingadvantage4.DataValue='Above quoted skylight will ship construction ready (K/D). Unit will be shop-assembled prior to shipment to ensure all components fit correctly. Unit will ship Knock Down. Rafters will be notched ready to accept purlins. Rafters will be gasketed with lugs attached. Purlins will be notched ready to accept rafters.  Purlins will be gasketed and have setting chairs attached. ';
    crmForm.all.synact_sellingadvantage5.DataValue='Above quoted unit is quoted as a Limited Thrusting Unit. Unit to control all gravity loads, wind loads will still act upon cubs. ';
    crmForm.all.synact_sellingadvantage6.DataValue='ALL HOISTING IS BY OTHERS. ';
    crmForm.all.synact_freight.DataValue = 'FOB Berwick, PA, prepaid to jobsite.';
    crmForm.all.synact_qualification1.DataValue = 'All Counter Flashing Not Provided with in this Proposal. ';
    crmForm.all.synact_qualification2.DataValue = 'Curb and substructure by Others. ';
    crmForm.all.synact_qualification3.DataValue = 'Curb must Resist all loads. ';
    crmForm.all.synact_qualification4.DataValue = 'Final Cleaning is by others. ';
    crmForm.all.synact_qualification5.DataValue = 'Minimum Field Fabrication May Be Required. ';
    crmForm.all.synact_qualification6.DataValue = 'All State & Local Taxes Excluded (6% Use Tax Included. ';
    crmForm.all.synact_qualification7.DataValue = 'Bonding is Excluded. ';

    crmForm.all.synact_qualification9.DataValue = 'If installation is included, work is assumed to be continuous. ';
    crmForm.all.synact_qualification10.DataValue = 'Standard Sill Detail utilized. If insulation in sill and voids is required, please consult factory. ';
    crmForm.all.synact_qualification11.DataValue = 'ACURLITE is a PA State Certified WBE owned and operated company. ';

    }

    // loop through fields and swap checkbox w/ label

    // add the names of the attributes you wish to switch to the array.
    var fields =new Array
    ("synact_framesonlyglassinstallationbyothers", "synact_materialsonlyinstallationbyothers","synact_curbsbyothersmustwithstandskylightloads","synact_structuralsteelbyothers","synact_regletsandcounterflashingbyothers","synact_guttersbyothers","synact_finalcleaningandprotectionbyothers","synact_5012watertest","synact_allglazingsealantsbackerrodbyothers") ;

    var n = (fields.length - 1);
    for (i=0;i<=n;i++)
    {
        var label = document.getElementById(fields[i] + "_c");
        var labelHTML = label.innerHTML;
        var data = document.getElementById(fields[i] + "_d");
        var dataHTML = data.innerHTML;
        label.innerHTML = dataHTML;
        data.innerHTML = labelHTML;
    }


    Ken Compter
    Sunday, October 3, 2010 2:01 PM
  • Hi, Ken.

     

    Actually it doesn't work because of following lines

    var CRM_FORM_TYPE_CREATE = 1; if (crmForm.FormType==CRM_FORM_TYPE_CREATE)

     

    When you click new from opportunity window - opened quote is already saved to DB. To make your script work you should use following code:

    if (crmForm.FormType==1 || crmForm.FormType == 2)

    {

    //Here is your logic

    }


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    • Proposed as answer by HIMBAPModerator Sunday, October 3, 2010 2:53 PM
    • Marked as answer by kcompter Monday, October 4, 2010 11:51 AM
    Sunday, October 3, 2010 2:12 PM
    Moderator
  • i will support andry's solution.
    Monday, October 4, 2010 4:48 AM
  • That was it.  It was also very helpful that you explained why it failed.  I did not know that when opening a quote from an opportunity it automatically saves on opening.  Thank you for the help!

    Ken


    Ken Compter
    Monday, October 4, 2010 11:53 AM