الأربعاء، 21 أكتوبر 2015

How To Get Base Currency in CRM 2011,2013,2015

QueryExpression query1 = new QueryExpression("transactioncurrency");
        query1.ColumnSet = new ColumnSet(new string[1] { "isocurrencycode" });
        QueryExpression query2 = query1;
        query2.AddLink("organization", "transactioncurrencyid", "basecurrencyid", JoinOperator.Inner);
        Entity entity = CrmServiceHelper.Service.RetrieveMultiple(query2).Entities[0];
        if (entity == null)
            return;
        string BaseCurrency = entity["isocurrencycode"].ToString().ToUpper();

الخميس، 20 أغسطس 2015

CRM Update Rollup 16:Action Microsoft.Crm.Setup.Common.Update.DBRemoveAction failed

When i try to uninstall the update rollup 16 i get the following error:

Action Microsoft.Crm.Setup.Common.Update.DBRemoveAction failed.

Exception has been thrown by the target of an invocation.

organization With Id = xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx Does Not Exist

Solution:
write the following query in SQL server for MSCRM_Config database:

Select FreindlyName from Organization
where Id='xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx'

then from the deployment manager disable and delete this organization.

الأحد، 26 يوليو 2015

Dynamics CRM 2013 :Read Sub-Grid Cell value

Here is sample code to get sub grid cell value in MS CRM 2013.

function GetSubGridCellValues() {
    if (document.getElementById("SubGridName")) {
        var grid = document.getElementById("SubGridName").control;
        var ids = gridControl.get_allRecordIds();
        for (i = 0; i < ids.length; i++) {
            alert(gridControl.getCellValue('fieldName', ids[i]));
        }
    }
    else {
        setTimeout("GetSubGridCellValues();", 1000);
    }
}

الخميس، 23 يوليو 2015

Disable Subgrid Control in CRM 2013

function DisableSubgrid(SubgridName) {
    var grid = document.getElementById(SubgridName);
    if (!grid) {
        setTimeout("DisableSubgrid('" + SubgridName + "');", 1000);
        return;
    }
    else {
        grid.control.add_onRefresh(function () {
            var gridCtrl = document.getElementById(SubgridName);
            document.getElementById('titleContainer_' + SubgridName).style.display = 'none';
            var nodes = gridCtrl.getElementsByTagName("tr");
            for (var i = 0; i < nodes.length; i++) {
                if (nodes[i].className == "ms-crm-List-Row-Lite") {
                    nodes[i].className = "";
                    nodes[i].removeAttribute("onmouseover");
                    nodes[i].removeAttribute("onclick");
                    nodes[i].removeAttribute("onmouseout");
                    nodes[i].onclick = function (evt) {
                        evt.stopPropagation();
                        evt.preventDefault();
                    }
                    nodes[i].ondblclick = function (evt) {
                        evt.stopPropagation();
                        evt.preventDefault();
                    }
                }
            }
        });

        document.getElementById('titleContainer_' + SubgridName).style.display = 'none';
        var nodes = grid.getElementsByTagName("tr");
        for (var i = 0; i < nodes.length; i++) {
            if (nodes[i].className == "ms-crm-List-Row-Lite") {
                nodes[i].className = "";
                nodes[i].removeAttribute("onmouseover");
                nodes[i].removeAttribute("onclick");
                nodes[i].removeAttribute("onmouseout");
                nodes[i].onclick = function (evt) {
                    evt.stopPropagation();
                    evt.preventDefault();
                }
                nodes[i].ondblclick = function (evt) {
                    evt.stopPropagation();
                    evt.preventDefault();
                }
            }
        }
    }
}