Thursday, May 28, 2009

How to login in console mode through Remote Desktop

Recently we came across a situation where we had to logon to a windows server remotely and yet open it in console mode. This means that we needed to be identified as being locally logged on instead of being treated as a remote desktop user.
We found that remote desktop command has various commandline arguments that can be used to connect. One of the arguments is /console which did the trick for us.
The command is mstsc /console
I hope this tip helps others with similar neeeds.

Monday, May 18, 2009

Form assistant

In CRM 3.0 there was no easy way to control the Form assistant window. We could get it done by making some changes to the customization file before importing into CRM.

In CRM 4.0, we have now been given the option to decide the Form Assistant settings for each entity. You are most likely to miss it and I have seen many queries on this.

To alter the Form assistant settings, follow the steps below:

1) Go to Settings => Customizations => Customize the entity in our case it is Product
2) Open product entity and go to Forms and views. Select the Form
3) Here, go to Form Properties => Display tab

Now, if both these checkboxes are checked you can see the form assistant open by default.

If, you uncheck the “Expanded by Default” checkbox, then the form assistant will be there but will not be open up by default as shown in the screen below:

Whereas, if you uncheck both the checkboxes i.e. “Expanded by Default” and “Enable form assistant”, then the form assistant will not be visible at all as shown in the screen below:

It is important to publish the entity after any customization change is made to it.

Tuesday, May 12, 2009

Bulk Delete Operations for Dynamics CRM 4 On-Premise

It is often that have you come across when you wanted to delete records from CRM in bulk.

The only option you have to delete multiple records in CRM is by selecting all records available in one page of a view and then hit delete. A view can have at max 250 records displayed. So if you need to delete more than that you have no choice but to navigate through each page and delete the records.

Since we do a lot of conversion projects we need to delete previously imported records before running the conversion. And this was too much of a task...

We started working on developing our own little project that will do the job. CRM has made available the BulkDeleteRequest Message in CRM SDK that allows us to delete more than one entity records at a time.

The BulkDelete Message will create an asynchronous job that can be monitored through the System Jobs Menu option.

You can provide the record selection criteria by specifying the query that needs to be executed to get the records over which the action needs to be performed.

If you want this to a recurring job to be executed say every x days, you can set the RecurrencePatern of the BulkDeleteRequest Message.

Since the bulk delete operation can be run on any entity and it requires a query to be provided, we thought of generalizing this. We developed a small tool that allows the users to specify the parameters for the Bulk Delete Job in user friendly interface. These jobs can be monitored in the system jobs window.

Anyone who would like to get this tool without having to re-invent the wheel can check details at

Monday, May 11, 2009

Error "Sub reports within table/matrix cells are ignored" when exporting SRS Reports to Excel

If you make an SRS report that uses Data table and has sub-reports included, you will see the below error when the report is exported to Excel.

Export to PDF format works just fine but when you export to Excel the excel file will not show the details included in the sub-report. Instead the sub-report will be replaced with a single line error "Sub reports within table/matrix cells are ignored".

To be able to export SRS reports using Sub-reports to Excel, it is advisable to use List controls instead of Data Table. Once you have made this little change, the export to excel is just perfect. Infact it will automatically even freeze the rows in the page header so that when you scroll through the data that was included in the report header stays static.

Hope this helps!

Thursday, May 7, 2009

Retrieve Marketing List Members

A Marketing list in CRM, can be a collection accounts or contacts or leads. Retrieving the members of a marketing list is not as as simple. We just realized that the list member entity only stores the link to the entity and Retrieve method is not supported by this entity.

Hence to retrieve the list members for a given entity we need to identify the type of entity being supported by the list i.e Leads/Accounts/Contacts and then using the link entity functionality link it with the listmember entity to get the list.

Following is the snippet of getting collection of accounts from a particular marketing list id.

//initialize QueryExpression for adding link entities
QueryExpression qe = new QueryExpression();
qe.EntityName = EntityName.account.ToString();
//Initialize columnset
ColumnSet col = new ColumnSet();

//add columns to columnset for the acc to retrieve each acc from the acc list
col.AddColumns(new string[] { "accountid", "name", "address1_line1", "address1_line2", "address1_city", "address1_stateorprovince", "address1_postalcode"});

qe.ColumnSet = col;

// link from account to listmember
LinkEntity le = new LinkEntity();
le.LinkFromEntityName =
le.LinkFromAttributeName = "accountid";
le.LinkToEntityName = EntityName.listmember.ToString();
le.LinkToAttributeName = "entityid";

//link from listmember to list
LinkEntity le2 = new LinkEntity();
le2.LinkFromEntityName = EntityName.listmember.ToString();
le2.LinkFromAttributeName = "listid";
le2.LinkToEntityName = EntityName.list.ToString();
le2.LinkToAttributeName = "listid";

// add condition for listid
ConditionExpression ce = new ConditionExpression();
ce.AttributeName = "listid";
ce.Operator = ConditionOperator.Equal;
ce.Values = new object[] { strList };//here “strList” is the marketing list id provided to this function.

//add condition to linkentity
le2.LinkCriteria = new FilterExpression();

//add linkentity2 to linkentity

//add linkentities to Query Expression which is passed for getting collection of accounts

//above query expression is passed to retrieve multiple for getting BusinessEntityCollection of accounts.
BusinessEntityCollection bec = service.RetrieveMultiple(qe);

Similarly you could link with Contacts/Leads to get the list of members from a Contact/Lead Marketing list.

Monday, May 4, 2009

Freeze header and the first column of the GridView control

There have been often times when the customers (familiar with Excel Freeze Options) have asked for the same functionality on ASP .NET forms.

There is no direct property that would allow users to either fix the header or the column. The html concept of was hard to find with GridView control.

We found a solution that used stylesheet to freeze the header and the columns. This code really helped us achieve our goals.

Here it is...
Place your gridview under DIV. This div should contains style value as

style="height:500px; width:100%; overflow:auto;"

overflow:auto: to display the scroll bars when grid contents exceeds the grid height

Instead of hard coding div height if you need to apply the height as the page height you can refer to the following article,

In gridview header provide class name from stylesheet i.e. Freezing
< cssclass="FreezeHeader" id="”">
The above line will freeze the header row

To freeze the first column use below code for first column at run time
gvFix.HeaderRow.Cells[0].CssClass = "locked";

foreach (GridViewRow row in gvFix.Rows)
{ //stylesheet to firstcol
row.Cells[0].CssClass = "locked";
Here are the Stylesheet classes that are being referred above

/* Locks the left column */
td.locked, th.locked {
cursor: default;
left: expression(document.getElementById("div_gridholder").scrollLeft); /* div_gridholder : name of the div which holds gridview*/

/* Locks the header */
.FreezeHeader {
position:relative ;
top:expression(this.offsetParent.scrollTop - 2);
z-index: 20;

Hope this helps others give the option of Freezing rows and columns in grid controls.