‏إظهار الرسائل ذات التسميات CRM 2011. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات CRM 2011. إظهار كافة الرسائل

الثلاثاء، 9 فبراير 2016

CRM 2013:Check record duplicate detection Using C# .

 Entity Account= new Entity("account");
            Account["name"] = "Test Account";
            Account["accountnumber"] = "111111111";

Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesRequest req = new Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesRequest
                {
                    BusinessEntity = Account,
                    MatchingEntityName = "account",
                    PagingInfo = new PagingInfo() { PageNumber = 1, Count = 50 }
                };

                Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesResponse resp = (Microsoft.Crm.Sdk.Messages.RetrieveDuplicatesResponse)Service.Execute(req);

                if (resp.DuplicateCollection.Entities.Count > 0)
                    continue;

الثلاثاء، 19 يناير 2016

CRM 2013 Error: Maximum record limit is exceeded. Reduce the number of records

When you open a chart in CRM 2013 and get this error "Maximum record limit is exceeded. Reduce the number of records", it's because the number of records to fetch is more than 50.000.

To solve do the following:

--****** get the number of records to be fetched ***********
Use MSCRM_CONFIG
Select IntColumn from [MSCRM_CONFIG].[dbo].[DeploymentProperties] 
where ColumnName = 'AggregateQueryRecordLimit'

--*********************** increasing the number of records to be fetched ***
Use MSCRM_CONFIG 
UPDATE [MSCRM_CONFIG].[dbo].[DeploymentProperties] 
SET [IntColumn] = '99999999' 
WHERE ColumnName = 'AggregateQueryRecordLimit'

الخميس، 7 يناير 2016

CRM 2011: Hiding Ribbon Button on Click/Select SubGrid using JavaScript.

function OnSubGridClicked() {
    var GridCtrl = document.getElementById("gridname");
    if (GridCtrl == null || GridCtrl.readyState != "complete") {
        setTimeout('OnSubGridClicked()', 1000);
        return;
    }
    else {
        GridCtrl.onload = HideRibbon;
        GridCtrl.onclick = HideRibbon;
        GridCtrl.onfocus = HideRibbon;
    }
}

function HideRibbon() {
    if (window.top.document.getElementById("RibbonId") != null) {
        window.top.document.getElementById("RibbonId").style.display = "none";
        setTimeout(" HideRibbon('"RibbonId"');", 200);
    }
}

الأربعاء، 6 يناير 2016

CRM 2011: Updating record the plugin was fired by / from does not work.


1- Register in Async-post-update with the check of

if (context.Depth > 1){ return; }  //To Avoid Multiple Trigger Of Same Update Plugin.

2- Register in Sync-post-update:
Try Creating a new Object for Updating the record Like

  Entity test=new Entity("contact");
  test.Id=((Entity)context.InputParameter["Target"]).Id;
  test.Attributes["firstname"]="ABC";
  service.Update(test);

الأربعاء، 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.

الجمعة، 1 مايو 2015

Open Entity Form (New/existing) using JavaScript

//Open a new contact record
Xrm.Utility.openEntityForm("contact");
//Open an existing contact record
Xrm.Utility.openEntityForm("contact","A85C0252-DF8B-E111-997C-00155D8A8410");
//Open a new contact record with a specific form and setting default values
var parameters = {};
parameters["formid"] = "b053a39a-041a-4356-acef-ddf00182762b";
parameters["name"] = "New Contact";
parameters["emailaddress"] = "email@example.com";
//For lookup
parameters["customerid"] = "257b689C8B47-8B9D-E111-883B-1CC1DEEA2718";
parameters["customeridname"] = "Test Cust";

Xrm.Utility.openEntityForm("contact", null, parameters);
//Open a new contact record, move it to the top left corner of the screen, and set the size of the window
var newWindow = Xrm.Utility.openEntityForm("contact");
newWindow.moveTo(0,0);
newWindow.resizeTo(800,600);

///*******************************************************
Opens an HTML web resource:

//**Open an HTML web resource named "new_webResource.htm":
Xrm.Utility.openWebResource("new_webResource.htm");



//**Open an HTML web resource including a single item of data for the data parameter
Xrm.Utility.openWebResource("new_webResource.htm","dataItemValue");



//**Open an HTML web resource passing multiple values through the data parameter
var customParameters = encodeURIComponent("first=First Value&second=Second Value&third=Third Value");
Xrm.Utility.openWebResource("new_webResource.htm",customParameters);

الأحد، 26 أبريل 2015

Open CRM Lookup window in a custom page

function OpenLookup() {
    var serverURL = "http://Server:5555/OrganizationName/_controls/lookup/lookupinfo.aspx?AllowFilterOff=1&DefaultType=2&DefaultViewId=%7b00000000-0000-0000-00AA-000010001004%7d&DisableQuickFind=0&DisableViewPicker=0&LookupStyle=single&ShowNewButton=1&ShowPropButton=1&browse=0&objecttypes=123";


    var lookUp = window.showModalDialog(serverURL, 'entity', "dialogwidth: 750px; dialogheight: 600px; resizable: yes");

    ///For get return values

    //var name = lookUp.items[0].name; var id = lookUp.items[0].id;
    if (lookUp != null) {
        var data = eval('(' + lookUp + ')');
        alert(data.items[0].name + ":" + data.items[0].id);
    }
}

الخميس، 16 أبريل 2015

How to assign Equipment/Facility to existed resource group.


//********* Create New Equipment/Facility *******************************
        Entity Equipment = new Entity("equipment");
        Equipment["name"]="Test Equipment 1";
        Equipment["timezonecode"]=1;
        Equipment["businessunitid"] = new EntityReference("businessunit", new Guid("BusinessUnitId"));

        Guid EquipmentId = _Service.Create(Equipment);
        //************************** Retrieve the Resource group***************
        Entity ResourceGroup = _Service.Retrieve("constraintbasedgroup", new Guid("ResourceGroupId"), new ColumnSet(true));
        //********************* Get the constrains of Resource group***************
        System.Text.StringBuilder builder = new System.Text.StringBuilder(ResourceGroup["constraints"].ToString());
        //******* Assing the equipment to resouce group ***************
        builder.Replace("</Body>", " || resource[\"Id\"] ==" + EquipmentId.ToString("B") + " </Body>");

        ResourceGroup["constraints"] = builder.ToString();
        //**************************** Update Resource Group***************
        _Service.Update(ResourceGroup);

الاثنين، 1 ديسمبر 2014

CRM 2011:JavaScript to Disply Sum of Column from Grid

1- For SubGrid

write the following JS code in the page load of CRM form:

function SubGridOnload() {
    //debugger;
    var grid = Xrm.Page.ui.controls.get('SubGrid_Name')._control;
    var sum = 0.00;
    if (grid.get_innerControl() == null) {
        setTimeout(subGridOnload, 1000);
        return;
    }
    else if (grid.get_innerControl()._element.innerText.search("Loading") != -1) {
        setTimeout(subGridOnload, 1000);
        return;
    }

    var ids = grid.get_innerControl().get_allRecordIds();
    var cellValue = "";
    for (i = 0; i < ids.length; i++) {
        if (grid.get_innerControl().getCellValue('cit_monthlyamount', ids[i]) != "") {
            cellValue = grid.get_innerControl().getCellValue('Filed_To_Sum', ids[i]);
            cellValue = (cellValue.substring(4)); //.replace(".00", "");
            var number = Number(cellValue.replace(/[^0-9\.]+/g, ""));
            sum = parseFloat(sum) + parseFloat(number);
        }
    }
    Xrm.Page.getAttribute("Field_To_Set_The_Sum").setValue(sum.toString());
}

2- For Home Grid:


function GetFieldSum() {
    //debugger;
    var sum = 0.00;
    var MonthlyAmountField_index = 0;
    
    if (window.document.getElementById('gridBodyTable') != null) {
        var gridBar = window.document.getElementById('gridBodyTable');
        if (gridBar != null && gridBar != "undefined") {
            var headers = gridBar.getElementsByTagName('TH');
            
            for (var index = 0; index < headers.length; index++) {
                var header = headers[index];
                switch (header.innerText) {
                    case "Monthly Amount":
                        MonthlyAmountField_index = index;
                        break;
                    default:
                        break;
                }
            }
        }
        if (MonthlyAmountField_index != 0) {
            //Get the Grid records
            var cellValue = "";
            var GridCtrl = window.document.getElementById('gridBodyTable');

            for (var i = 1; i < GridCtrl.rows.length; i++) {
                var cellObj = GridCtrl.rows[i].cells[MonthlyAmountField_index];
                if (cellObj != null) {
                    cellValue = cellObj.innerText;
                    cellValue = (cellValue.substring(4));
                    var number = Number(cellValue.replace(/[^0-9\.]+/g, ""));
                    sum = parseFloat(sum) + parseFloat(number);
                }
            }
        }
    }
    var ItemsSelectedInfo=window.document.getElementById('crmGrid_ItemsSelectedInfo');
    if (ItemsSelectedInfo != null) {
        var FieldDataSum = window.document.getElementById('crmGrid_FieldDataSum');
        if (FieldDataSum == null) {
            var label = document.createElement('span');
            label.id = "crmGrid_FieldDataSum";
            label.style.backgroundColor = 'yellow'
            label.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Total=</b>" + sum.toString();
            ItemsSelectedInfo.appendChild(label);
        }        
        //alert(sum);
    }      
}


الجمعة، 28 نوفمبر 2014

How to colorize a grid rows in CRM 2011 & 2013

1- Write the following JS code:
function ColorizeGridRows() {
    //debugger;
    var StatusField_index = 0;
    
    var iColumns = 0;
    if (window.document.getElementById('gridBodyTable') != null) {
        var gridBar = window.document.getElementById('gridBodyTable');
        if (gridBar != null && gridBar != "undefined") {
            var headers = gridBar.getElementsByTagName('TH');
            //Total no. of columns in the view
            iColumns = headers.length;
            for (var index = 0; index < headers.length; index++) {
                var header = headers[index];
                switch (header.innerText) {
                    case "Status Reason":
                        StatusField_index = index;
                        break;
                    default:
                        break;
                }
            }
        }
        if (StatusField_index != 0) {
            //Get the Grid records
            var GridCtrl = window.document.getElementById('gridBodyTable');
            _iTotalRecords = GridCtrl.rows.length - 1;
            //GridCtrl.rows[0].style.display = 'none';
            for (var i = 1; i < GridCtrl.rows.length; i++) {
                var cellStatus = GridCtrl.rows[i].cells[StatusField_index];
                if (cellStatus != null) {
                    if (cellStatus.innerText == "Accepted") {
                        GridCtrl.rows[i].style.backgroundColor = 'green';
                    }
                    else if (cellStatus.innerText == "Rejected") {
                        GridCtrl.rows[i].style.backgroundColor = 'red';
                    }
                }
            }
        }
    }
}


2- Add the Above JS code to web Resource and add the web resource to entity form.
3- Add button to Main Grid ribbon called "Colorize Grid".
4- Set the Enabled rule for this button to JS function as below:


الاثنين، 11 أغسطس 2014

SQL Timeout solutions in Dynamics CRM 2011

Mostly this kind of problems could come from Plugins, if there are any plugins executed on that action.

Increase the default timeout

Registry on CRM applicationserver(s)
  1. Open CRM Web Server(where CRM is installed)
  2. Open regedit (start – > write ( regedit) ) and press ok
  3. Go to HKEY_LOCAL_MACHINESOFTWAREMicrosoftMSCRM
  4. Add DWORD name OLEDBTimeout with value 86400 ( 24 hours) select decimal
  5. Add DWORD name ExtendedTimeout with value 1000000. The maximum value can be 2,147,483,647 and the default value is 30 seconds
These changes in register should fix the SQL timeout.

الأحد، 6 أبريل 2014

السبت، 1 فبراير 2014

CRM 2011:The specified record type does not exist in microsoft dynamics crm

It appears your sitemp has reference to entity not found.
"contains reference to entity new_tribute but that entity was not found in the metadata cache"
go to SiteMap then delete this entities and update sitemap then it will work.