locked
Old CRM 4.0 Javascripts (hard to make sense of) RRS feed

  • Question

  • We're in the process of moving an on premise CRM from 4.0 to 2013.   Our goal is just to get an idea of what the original programmer was trying to do - and replicate the functionality in 2013 ideally NOT using javascript (but using javascript if necessary).

    We've figured out a lot by ourselves.  In these blocks of code we can use some advice.  All of this pertains to the account entity.  If you can, please explain what you think the programmer was trying to acheive and the most practical method for achieving it in 2013.

    By the way: & means &
    &#60;  means <


    Code Block 1:
    var disable = false;
    crmForm.all.ftgbase_accounttypeid.Disabled = disable;

    if (crmForm.all.ftgbase_accounttypeid &#38;&#38; crmForm.all.ftgbase_accounttypeid.DataValue != null)
    {
        disable = (crmForm.all.ftgbase_accounttypeid.DataValue[0].name == "Distributor");
    }

    crmForm.all.ftgbase_accounttypeid.Disabled = disable;

    for (var ctr = 1 ; ctr &#60;4 ; ctr++)
    {
       var lu = crmForm.all("ftgbase_userdefined" + ctr + "id");

        if (lu != null)
        {
            if (crmForm.all.ftgbase_accounttypeid.DataValue != null)
            {
                lu.AddParam("search", crmForm.all.ftgbase_accounttypeid.DataValue[0].name);
                lu.Disabled = false;
            }
            lu.Disabled = (disable || crmForm.all.ftgbase_accounttypeid.DataValue == null);
        }
    }


    -------------
    Code Block 2:
    window.ftgAddRelatedRecord = new Function("fromType", "relatedType", "var sUrl = '?_CreateFromType=' + fromType + '&#38;_CreateFromId=' + crmForm.ObjectId; openFrmObj( sUrl, buildWinName(), relatedType );");

    window.ftgAddTask = new Function("type", "var sParentId   = null; var sParentType = null; var sParentName = null; var accountId = crmForm.ObjectId;sParentId   = crmForm.ObjectId; sParentType = 1; sParentName = crmForm.all.name.DataValue; addActivityTo(type, sParentId, sParentType, sParentName, null, null, null, null, null);");


    ----------------
    Code Block 3:
    window.snapshotreport = new Function("var SERVER_URL = window.location.protocol + '//' + window.location.host; var url = SERVER_URL + '/crmreports/viewer/viewer.aspx?action=run&#38;id={FDDCE2E1-DD32-DE11-BAE5-000C29BFF7C5}&#38;context=records&#38;recordstype=1&#38;records=' + crmForm.ObjectId + '&#38;helpID=Customer%20Snapshot.rdl'; var x = window.showModalDialog(url,'','dialogWidth:735px;dialogHeight:550px');");

    var navElement = document.getElementById('nav_ftgbase_snapshot_report');
    if (navElement != null)    
    {
        navElement.onclick = function LoadAreaOverride()
                        {
            snapshotreport(); event.cancelBubble = true;
        }
    }

    var userId2 = getUserId();

    ---------------------
    Code Block 4:
    var accountId = crmForm.ObjectId;
    window.CompetitiveInfo = new Function("var SERVER_URL = window.location.protocol + '//' + window.location.host; var url = SERVER_URL + '/ISV/competitiveinfo/products.aspx?orgId=9ddfde93-3d6a-dd11-be84-000c29bff7c5&#38;salesCallId="+accountId +"&#38;userId="+userId2+"&#38;time=1284312665602'; var x = window.showModalDialog(url,'','dialogWidth:735px;dialogHeight:550px');");


    -----------------------
    Code Block 5
    UpdateAssociatedCompetitiveInfoButtons('account_ftgbase_competitiveInfos', 'Add existing Competitive Info to this record');

    function UpdateAssociatedCompetitiveInfoButtons(loadAreaId, buttonTitle)
    {
       var navElement = document.getElementById('nav_account_ftgbase_competitiveInfos');
        if (navElement != null)
        {
            navElement.onclick = function LoadAreaOverride()
            {
                // Call the original method to launch the navigation link
                loadArea(loadAreaId);

                var associatedViewIFrame = document.getElementById('account_ftgbase_competitiveInfosFrame');
                if (associatedViewIFrame != null)
                {
                    associatedViewIFrame.onreadystatechange = function HideTitledButton()
                    {
                        if (associatedViewIFrame.readyState == 'complete')
                        {
                            var iFrame = frames[window.event.srcElement.id];
                            var liElements = iFrame.document.getElementsByTagName('li');
                            for (var i = 0; i &#60; liElements.length; i++)
                            {
                                if (liElements[i].getAttribute('title') == 'Add a new Competitive Info to this record')
                                {
                                    liElements[i].onclick = function LoadAreaOverride()
                                    {
            CompetitiveInfo();
                                              // event.cancelBubble = true;
                                    }

                               //     liElements[i].style.display = 'none';
                                //    break;
                                }

                                if (liElements[i].getAttribute('title') == 'Add existing Competitive Info to this record')
                                {
                                    liElements[i].style.display = 'none';
                                    break;
                                }

                            }
                        }
                    }
                }
            }
        }
    }

    Tuesday, February 3, 2015 10:25 PM