Saturday, June 2, 2012

Update Navigation URL in MS CRM 2011

// Update Navigation URL


    UpdateNavItemUrl: function (linkLabel,iframeUrl) {
       
        var items = Xrm.Page.ui.navigation.items.get();
        for (var i in items) {
            var item = items[i];
            var itemLabel = item.getLabel();
            //      alert(itemLabel);
            if (itemLabel.toLowerCase() == linkLabel.toLowerCase()) {
                //     alert(itemLabel);
                var areaId = item.getId();
                var navElement = document.getElementById(areaId);

                if (navElement != null && navElement != undefined) {
                    //         alert(iframeUrl);
                    navElement.onclick = function () {
                                                loadIsvArea(Mscrm.CrmUri.create(iframeUrl), false);
                                                var navIframeObject = document.getElementById(areaId + 'AreaFrame');
                                                navIframeObject.src = iframeUrl;
//TO Open in seperate window (popup)
                       // var windowL = (screen.width - 1000) / 2;
                        var windowT = (screen.height - 607) / 2;
//
  //                      window.open(iframeUrl, '', 'status=yes,location=no,menubar=no,resizable=no,height=607,width=1000,left=' + windowL + ',top=' + windowT);
                    };
                }
            }
        }
    }