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

الخميس، 13 يوليو 2017

Dynamics 365: Adding Bing Map control to forms of custom entity

Starting from CRM 2013 Microsoft released a really great feature OOB (Out Of the Box) integration with BingMaps. Unfortunately, the list of entities that support BingMaps control is limited to Account, Contact, Lead, Quote, Order, Invoice, Competitor, and System User.So when trying to add Bing Maps to form the icon is grayed out on the insert ribbon for a form - in particular for a custom form.

To Solve this issue follow the below link:

الأحد، 12 يونيو 2016

How to get entity Image and display in ASP.Net Gridview in CRM 2013/2015

//Get the Image of Product for CRM Online.

public static DataTable GetProductWithImages()
        {
            try
            {

                OrganizationService _service = new OrganizationService(CRMConnection);
                
                DataTable dTable = new DataTable();

                dTable.Columns.Add("Name");
                dTable.Columns.Add("Id");
                dTable.Columns.Add("Image",typeof(byte[]));

                string Fetch = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                                  <entity name='product'>
                                    <attribute name='name' />
                                    <attribute name='producttypecode' />
                                    <attribute name='productnumber' />
                                    <attribute name='entityimage' />                                    
                                    <attribute name='productid' />
                                    <order attribute='name' descending='false' />
                                    <filter type='and'>
                                      <filter type='or'>
                                        <condition attribute='statecode' operator='eq' value='0' />
                                        <condition attribute='statecode' operator='in'>
                                          <value>3</value>
                                          <value>0</value>
                                        </condition>
                                      </filter>
                                    </filter>
                                  </entity>
                                </fetch>";

               
                EntityCollection Product = Common._service.RetrieveMultiple(new FetchExpression(Fetch));
                if (Product != null && Product.Entities.Count > 0)
                {
                    foreach (Entity ent in Product.Entities)
                    {
                        DataRow dRow = dTable.NewRow();
                        if (ent.Attributes.Contains("name"))
                            dRow["Name"] = ent.Attributes["name"].ToString();
                        if (ent.Attributes.Contains("productid"))
                        {
                            string ProductId = ent.Attributes["productid"].ToString();
                            dRow["Id"] = ProductId;
                        }

                        if (en.Attributes.Contains("entityimage"))
                        {
                            dRow["Image"] = en.Attributes["entityimage"] as byte[];
                        }
                        else
                            dRow["Image"] = null;

                        dTable.Rows.Add(dRow);
                    }
                }

                return dTable;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

//**** now to display in asp gridview do the follwing:

// **** In ASPX*****
<asp:GridView ID="grvProduct" runat="server" AutoGenerateColumns="False" Width="90%">
    <Columns>
        <asp:TemplateField HeaderText="Quantity">
            <ItemTemplate>
                <img src='<%# Eval("Image") != System.DBNull.Value ? string.Format("data:image/jpg;base64,{0}",Convert.ToBase64String((byte[])Eval("Image"))) : "Images/No_image.jpg" %>' alt="image" height="144" width="144" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>


//**** In code behind *****

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            FillGrid();
        }
    }
    public void FillGrid()
    {
        grvProduct.DataSource = GetProductWithImages();
        grvProduct.DataBind();
    }

الثلاثاء، 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'

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

الأحد، 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();
                }
            }
        }
    }
}

الخميس، 25 يونيو 2015

CRM 2013 Error:Unable to Change Domain Logon Name

When I am trying to add the new user on CRM 2013, i am getting the following error:
"Unable to Change Domain Logon Name"

To solve this issue do the following: 
1- In your CRM server, go to services.msc and check if the "Workstation" service is set to automatic and started 
2- Make sure you have the "AutoGroupManagement" value set to 1 (false) in your registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM)

الجمعة، 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);

الاثنين، 20 أبريل 2015

Dynamics CRM 2013:Get/Set Business Process stage field value.

Xrm.Page.getControl("header_process_fieldname").getAttribute().setValue(value);  //Set Value

Xrm.Page.getControl("header_process_fieldname").getAttribute().getValue();  //Get Value

 //****** get the Id of business process Satge*******************************
    var StageId = Xrm.Page.getAttribute("stageid").getValue();
    
    if (StageId == "7f5247fe-cfc3-42bc-aa77-b1d836d9b7c0") {
        var Control = Xrm.Page.getControl("header_process_fieldname").getAttribute();
//fire onChange event.
        Control.addOnChange(FunctionName);
    }

الأربعاء، 25 فبراير 2015

الأربعاء، 14 يناير 2015

CRM 2013: Data Encryption error

Microsoft Dynamics CRM 2013 uses standard SQL Server cell level encryption for a set of default entity attributes that contain sensitive information, such as user names and email passwords.
when you try to update user email in user entity you will get the following error:

when you open log file you see the error details "Cannot open Sql Encryption Symmetric Key because Symmetric Key password does not exist in Config DB."
To solve this problem (CRM on premises) :
1- Open SQL server management tool and form CRM database select new query the write the following script:
SELECT [ColumnName],[BitColumn]
FROM [MSCRM_CONFIG].[dbo].[DeploymentProperties]
WHERE ColumnName='DisableSSLCheckForEncryption'

UPDATE [MSCRM_CONFIG].[dbo].[DeploymentProperties]
SET [BitColumn]=1
WHERE ColumnName='DisableSSLCheckForEncryption'


After performing an IISReset on the CRM Server, you’ll be able to see the encryption screen.  Paste the encryption key in to a "CRM > Settings > Data Management > Data Encryption" screen, such as Notepad then click change. As a best practice, save the text file that contains the encryption key on a computer in a secure location on an encrypted hard drive
(if data Encryption status is inactive and current encryption key is null you can use guideGen.exe to generate key then past the the encryption key into "CRM > Settings > Data Management > Data Encryption" screen then click Activate)