Monday, October 24, 2011

Quick Select records from Form - Display Field

The one thing that I noticed while playing around with CRM 2011 is the emphasis that has been paid to a smooth user experience. Specifically, you will notice that there are short cuts to open/ create records that will save you extra clicks. This post will focus on the quick select feature in a record, and the field that is displayed, and how that can be changed.

If you are in the Account record, you can get to other account records by selecting the Accounts drop down, at the top right hand corner, just below the ribbon. For Account, the display field is the Account Name. What if you want to see the Account Number instead of the Account Name?
























Before we get to making any changes, you will notice that the Account Name is the Primary Field for the Account entity. That is the reason for field Account Name to show up in the quick select drop down.



























Another thing you will notice from figure 1 is that the view being used is called "My Active Accounts" which is the default public view for the Account entity. Now we know what view to modify!

























Double click the view "My Active Accounts", select "Add Columns", pick "Account Number" and select "Ok". Move Account Number all the way to the left. Save and Close the view, and publish the changes.





























Select F5 on your machine to refresh the crm web client, and go to Accounts. Open a record and check the quick select drop down. What field is displayed, and why?

Well, you still see the Account Name field in the drop down! That is due to the fact that Account Name is the primary Field. So any view that has Account Name as one of its columns, and is set as the default view, will use Account Name as the drop down field.


In order to change it, you will have to remove the Account Name from the view. Remember that the field is still on the account form (and is business required).



























Now, the drop down field will be the first column of the default view, instead of the Account Name. In our case, it will be the Account Number that shows up. Note that since Account Number is not a required field, you might see blank values in the drop down list. So, put some thought into selecting the right field to show up!


























The one nit pick with the above approach is that I do not see the Account Name anymore in my default view.



















To get around that, create a new text field called AcctName, make sure the max length is equal to or more than the account name (in this case 160), and add the field to the form. Make it a invisible field.

Create a JS web resource that copies the value of the Account Name from the name field to the new_acctname field. Something simple like the one below should work:

function CopyName() {
    
var accName = Xrm.Page.getAttribute("name").getValue() ;
if (accName != null)
  {
 Xrm.Page.getAttribute("new_acctname").setValue(accName );
  }

} 

Add the JS webresource both to the form onload() and account name onchange() event. Thus, each time a form is loaded or account name field is changed, the new field picks up the values when the form is saved. Remember to Save and Close when you open the account form, even if you did not make changes.

Final step is to add the new_acctname field to the "My Active Accounts" view. Now you have the view you want, with the drop down showing the field you need!

No comments:

Post a Comment