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


الأحد، 12 أكتوبر 2014

Sharepoint Error:"Access denied by Business Data Connectivity. Correlation ID:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx"

 When Create External Content Type Using SQL and  try to open List from site and you get the following error:

"Access denied by Business Data Connectivity. Correlation ID:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxx".
to solve this error do the follwing steps:
1- Open Sharepoint central administration
2- 

الأربعاء، 13 أغسطس 2014

Using CURSOR in SQL

Declare @AppId as varchar(50)
Declare @InvoiceNo as varchar(50)
declare @DueDate as datetime

DECLARE AppCURS CURSOR FOR

select cit_applicationno,new_InvoiceNo,cit_DueDate from ZmZm_MSCRM.dbo.cit_application where statuscode=912660015

OPEN AppCURS
fetch next from AppCURS into @AppId,@InvoiceNo,@DueDate
WHILE @@FETCH_STATUS = 0
BEGIN  
update AX2012R2_DB.dbo.PURCHTABLE 
set 
CRMINVIOCENUM=@InvoiceNo,
ACCOUNTINGDATE=@DueDate,
ISINVOICERECEIVED=1
where VENDORREF=@AppId

fetch next from AppCURS into @AppId,@InvoiceNo,@DueDate
END   

CLOSE AppCURS   
DEALLOCATE AppCURS

الاثنين، 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.

الأربعاء، 28 مايو 2014

Error message when you try to start a server that is running the AOS service in Microsoft Dynamics AX 2012 "Windows could not start the Dynamics Server$01 on Local Computer"

-In SQL in the newly restored database go to Security > Users.  Right-click on Users and choose new user.  Add the user account that runs the AOS service.  For me, this is my domain account.  
-In the middle of this user form, under Owned Schemas mark db_owner
-Still in the same form where you added the user, under Database role membership mark db_datareader, db_datawriter, and db_owner.
-In SQL in the newly restored database go to Programmability > Stored Procedures and right-click on CreateServerSessions and choose Properties.
-Click Permissions and click the Search button.  Find the account you just added to the database as a user, for me this is my domain account.
-In the bottom of this form under the Grant column mark all of the choices.
-In SQL in the newly restored database go to Programmability > Stored Procedures and right-click on CreateUserSessions and choose Properties.
-Click Permissions and click the Search button.  Find the account you just added to the database as a user, for me this is my domain account.
-In the bottom of this form under the Grant column mark all of the choices.