Wednesday, September 30, 2009

Appropriate W3P.exe instance while debugging the MS CRM Application

There are more than one W3P.exe instances running in a CRM system (CRM app pool, reporting service etc). While debugging the MSCRM Application sometimes we get more than one W3P.exe instances. And usually we attach all those instances which slowdowns the processing of the system.

It’s unnecessary overload on system processing. We can avoid this by attaching the appropriate W3P.exe instance.

To find out which instance to attach in debugger just run the IISAPP.VBS in command prompt, it will list out all the W3P.exe instances with their port no. Now just match the port no of the CRM App Pool/ Default App Pool with the available processes list, attach the appropriate W3P.exe and start debugging.

Tuesday, September 29, 2009

CRM Report error in case of Custom DB Object in MS CRM 4.0

While doing the reports for CRM, sometimes its required to create our own custom objects (like function, procedure or table) and use them in reports or to include some CRM tables(Entity, Attribute) in our Query.

When we use a custom object or CRM table in our Query it work perfectly for the admin user but it doesn’t work for the non-admin user.

In this case we need to add the permission “NT Authority\Network Services” for that particular object in DB.

Monday, September 28, 2009

Lookup: Retrieve Column values from Lookup window in MS CRM 4.0

if(Xrm.Page.getAttribute("<lookupId>") != null)
{
var entityId = document.getElementById( "<lookupId>");
var lookupItems = entityId.items[0].values;

alert(lookupItems[0].value); // First column value of Lookup
alert(lookupItems[1].value); // Second column value of Lookup
alert(lookupItems[2].value); // Third column value of Lookup
alert(lookupItems[3].value); // Fourth column value of Lookup
alert(lookupItems[4].value); // Fifht column value of Lookup
alert(lookupItems[5].value); // Sixth column value of Lookup
}

Note: You should disable the Automatic Resolution, so that users cannot add values automatically. This script will work only if the Lookup View is loaded.

Change the text and display of the navigation item in MS CRM 4.0

Change the text and display of the navigation item:-



var iOpps = 0;
if(document.getElementById('navOpps') != null)
{
document.getElementById('navOpps').getElementsByTagName('NOBR')[0].innerText =
document.getElementById('navOpps').getElementsByTagName('NOBR')[0].innerText + " (" + iOpps + ")";
document.getElementById('navOpps').getElementsByTagName('NOBR')[0].style.color = "#FF0000";
document.getElementById('navOpps').getElementsByTagName('NOBR')[0].style.fontWeight = "700";
}

Thursday, September 10, 2009

Change the color of the service appointment / appointment in service calendar in MS CRM 4.0

In Service Management, there are Time Blocks displayed in the appointment book. The color of the time blocks varies according to the status of the appointment. The section named “ServiceManagement” of isv.config.xml allows for customization of these colors by providing a mapping to the .css file that defines them. These .css files are located at \SM\Gantt\style\GanttControl.css.aspx.

Export and open the “isv.config”, search for the . Under the , for every Status(1 – Requested, 2 – Tentative, 3 – Pending, 4 – Reserved, 6 - In Progress, 7 – Arrived, 8 – Completed, 9 – Canceled ,10 - No Show) CssClass has been defined.

Open the GanttControl.css.aspx file using VS and search the CssClass name (like ganttBlockServiceActivityStatus1, ganttBlockServiceActivityStatus2) and change the color acording to your requirement.

Wednesday, September 9, 2009

Script for hide 'Add existing button' in MS CRM 4.0

Sometimes it required to hide the “add existing” button from the grid. Here is the Jscript to achieve the same. There is a Test entity (custom entity) in Contact entity where I am hiding the “add existing” button.

//Script for hide 'Add existing button'

HideAddExistingButton('new_contact_test', ['Add existing Test to this record']);

function HideAddExistingButton(relationshipName, buttonToolTip)
{
var navElement = document.getElementById('nav_' + relationshipName);
if (navElement != null)
{
navElement.onclick = function LoadAreaOverride()
{
loadArea(relationshipName);
HideButton(document.getElementById(relationshipName + 'Frame'), buttonToolTip);
}
}
}



function HideButton(Iframe, buttonToolTip)
{
Iframe.onreadystatechange = function HideTitledButtons()
{
if (Iframe.readyState == 'complete')
{
var iFrame = frames[window.event.srcElement.id];
var liElements = iFrame.document.getElementsByTagName('li');

for (var j = 0; j < buttonToolTip.length; j++)
{
for (var i = 0; i < liElements.length; i++)
{
if (liElements[i].getAttribute('title') == buttonToolTip[j])
{
liElements[i].style.display = 'none';
break;
}
}
}
}
}
}


“relationshipName” you can get it from the entity customization, it’s basically the relationship name in between the entities. “buttonToolTip” is the tool tip defined for the add exixting button.

Thursday, September 3, 2009

How to change the record title in MS CRM 4.0

Sometimes we get requirement like change the opportunity title or account title , it should be in red color based on some condition or title should be combination of few fields there in the form.


Here is the Jscript to achieve the same.

//Change the Main Title
var cells = document.getElementsByTagName("span");
for (var i = 0; i < cells.length; i++)
{
if (cells[i].className == "ms-crm-Form-Title")
{
cells[i].style.color = "#FF0000";
cells[i].style.fontWeight = "700";
break;
}
}





Tuesday, September 1, 2009

Bulk 'save as completed/Cancel' of the CRM activities in MS CRM 4.0

There is no direct way to do the same in CRM. But there are workarounds you can achieve the same.
1. Create an ISV button on the grid tool bar. On click of this button you will the GUID of all the selected records (in the grid). Once you will get the GUID of all the activity, you can call web service using Jscript (AJAX call) and update these records as completed.

getSelected('crmGrid') will return you an array of the GUIDs of the selected records.

Limitation –

· getSelected('crmGrid') method has a limitation , it will return you the GUID of max 50 records.

· After updating the activity using AJAX call, records will still appear in the grid, unless n until you will refresh the grid.

2. Create an ISV button on the grid tool bar. On click of this button you will the GUID of all the selected records (in the grid). Once you will get the GUID of all the activity, you call you own custom page, which will update those records as completed, and it will show you a user friendly message. On close of this custom page refresh the grid.

To Refresh the grid - crmGrid.Refresh();

limitation of creating the custom attributes in MS CRM 4.0

There is no limitation of creating the custom attributes in CRM. You can create n no of attributes within an entity. Bt as you know we have tables corresponding to each n every entity in the CRM DB and there is a limitation in database level. SQL Server allows up to 1024 columns per table and the amount of data stored in any row cannot exceed 8060 bytes. If so, while creating or updating CRM page will through SQL server error or sometimes it won’t allow you to perform any operation on this entity/records.

You can determine the number of bytes available for entities by running the following query in _METABASE database.

select e.Name, Bytes_Remaining = 8060 - (sum(a.length))from entity e
join attribute a on e.entityid = a.entityidwhere a.iscustomfield = 1
and a.islogical = 0group by e.Name

You can determine the number of bytes used for entities by running the following query in _METABASE database.

select e.Name, Physical_Size = sum(a.length)from entity e
join attribute a on e.entityid = a.entityidwhere a.iscustomfield = 1
and a.islogical = 0group by e.Name

More than 10,000 records not returned by CRM service in MS CRM 4.0

There is a limitation in CRM service, when we retrieve data using
RetrieveMultiple or fetch xml; actually it returns max 10,000 records.

There is an unsupported way to increase the no of records returned by CRM service. You need to update the CRM DB.

There is a table named “OrganizationBase”, in this you have a column named “MaxRecordsForExportToExcel”, which defines the no of records returned by CRM service.

By default this column has been set to 10,000, which we can change according to our requirement.

Or we can use direct SQL query for the same.