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

الاثنين، 5 يناير 2015

AX2012:Assembly xxxxx containing type is not referenced

assembly works in job but not with the sysoperationFW.
Solution: 
 - Copy ddl to the "Program Files\Microsoft Dynamics AX\60\Sever\[Your AOS Name]\bin\VSassemblies" folder
 - Added the AOS account to the dll file.
- Restarted AOS.

الخميس، 18 ديسمبر 2014

AIF Sales Order Create - SalesType being set to Journal

This is happening because, when we create a new Sales order using AIFservice, TheMaine Sales Order class checksis this the first sales order given by the customer, if so, then it put its order type = Sales Order but if the sales order is for a second or more time from the same customer than it put its order type= Journal. It checks all this with the help of PurchOrderFormNum field which is mandatory for creating sales orders from AIF. So the solution for it is to comment some code.
for that you need to go AOT-->Classes-->AxdSalesOrder-->prepareSalesTable() method and comment following code.
if (!_axSalesTable.salesTable())
    {
        createRecord = true;
        _axSalesTable.parmSalesType(this.salesType());


        select firstonly RecId from localSalesTable
            where localSalesTable.CustAccount       == _axSalesTable.parmCustAccount()
               && localSalesTable.PurchOrderFormNum == _axSalesTable.parmPurchOrderFormNum()
               && localSalesTable.SalesId           != _axSalesTable.parmSalesId();



      //  if (localSalesTable.RecId)
       // {
       //     _axSalesTable.parmSalesType(SalesType::Journal);
       // }
.
.
.
    }

Then, update service . Redeploy it and use it in your C# program. It will solve your problem.
//************************************** And Then *********************************************
To work around this problem, change the code in the first line after the hanging semicolon of the \Classes\AxdSalesOrder\prepareSalesTable object as follows.
Existing code
_axSalesTable.parmSalesType(this.salesType());

Replacement code
    if(enum2int(_axSalesTable.parmSalesType()) == 3)
        _axSalesTable.parmSalesType(SalesType::Sales);
    else
        _axSalesTable.parmSalesType(this.salesType());
///******************************************************
set the sales order parameter to "Sales Order" under the following path :-
 Accounts receivable -> Setup -> Accounts receivable Parameters -> AIF -> Order Type

الأحد، 14 ديسمبر 2014

ax 2012 user is not authorized for this port

ItemServiceClient Service = new ItemServiceClient()
 //********* Add the following to your code *********
Service.ClientCredentials.Windows.ClientCredential.Domain = "domain";
Service.ClientCredentials.Windows.ClientCredential.UserName = "username";
Service.ClientCredentials.Windows.ClientCredential.Password = "password";
Service.Open();
.
.
.
.
 CallContext ctx = new CallContext() { Company = "dat" };
  ctx.MessageId = Guid.NewGuid().ToString();
  ctx.LogonAsUser = String.Format(@"domain\username");

الاثنين، 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);
    }      
}