12 May 2010

Remove Advanced Find

I was recently asked if it is possible to remove Advanced Find from the user interface. My initial answer was: no and there's no need as a user can only search on data that they are allowed to. This didn't cut it as with Advanced Find it's possible to add columns which the users aren't supposed to see. There were some other details which I won't go into, suffice to say it had to go!

The following example will remove the advanced find but, it by an UNSUPPORTED METHOD, use it at your own risk!

This change involves adding some JavaScript to loader.aspx, before continuing make sure that it's been backed up first.

1. Open loader.aspx in a text editor of your choice.

2. Add the following JavaScript function just before the tag.

<script language="JavaScript" type="text/javascript">
function HideAdvancedFind()
{
//Check whether the iframe is completely loaded or not
if(document.getElementById("stage").readyState != "" && document.getElementById("stage").readyState!="loading")
{
try
{
document.frames[0].document.getElementById("btn_advfind").style.display="none";
document.frames[0].document.getElementById("_MIopenAdvFind").style.display="none";
}
catch(e)
{
}
}
}
</script>


3. Locate the frame named "menuBar" and just before the end of the tag add:

onreadystatechange="Javascript: HideAdvancedFind()"


4. Save and close loader.aspx and fire up CRM. The Advanced Find button has been removed from the menu-bar and the Tools menu.
Note: An IISReset may be necessary to clear the cache.

The finished result:




10 May 2010

Add a Button To a CRM 4.0 Form

There are some instances where it would be nice to be able to add a button straight on the CRM form. Unfortunately CRM doesn't provide a button control that can be added to the form. The alternative is to include the functionality to the menu-bar via the ISV.Config.

This blog will show you how to add a button to the form. This is a bit of smoke and mirrors really as we'll made a CRM attribute to appear to be button. The finished result looks like this:


The following steps will guide you through how the above was achieved:

1. Add a new text attribute to your entity, for this example it was called new_button. I set the maximum text length to 5, but the length is unimportant to this functionality.

2. Add a new section to the form, change the section formatting to 4 columns.
CRM Section Formatted to 4 columns



3. Add the new text attribute (new_button) to the new section that's just been created.

4. Change the Field Properties for new_button and ensure that Display Label on Form is un-checked.
CRM Attribute properties

5. The next step is to make the text-box look like a button, add the following to the form onLoad :

//Define the button style
var buttonStyle="font-family: Tahoma; font-size: 11px; line-height: 18px; height: 20px; width: 84px; text-align: center; cursor: pointer; border: 1px #3366CC solid; background-color: #CEE7FF; background-image: url('/_imgs/btn_rest.gif'); background-repeat: repeat-x; border: 1px #3366CC solid; padding-left: 5px; padding-right: 5px;";

//Set the style
crmForm.all.new_button.style.cssText=buttonStyle;

6. Now we need to set the button text:

//Set the button text, and don't allow it to be edited
crmForm.all.new_button.DataValue="Upload";
crmForm.all.new_button.contentEditable = false;

7. Finally the button needs to do something so we'll add the following:

//Define what the button is going to do
buttonClicked = function()
{
alert("Upload process started");
}

//Set the button's on-click event
crmForm.all.new_button.attachEvent("onclick",buttonClicked);

The above example will work for CRM 3.0 as well but you'll need to change the style to make it fit in.

As of version 4.0.10 the SDK provided stylesheets to allow any custom development to match the CRM look and feel. Download the SDK here. Once unpacked look at the sdk\stylesheet folder details.

New CRM SDK Released. Includes LINQ

The latest version of the CRM 4.0 SDK, 4.0.12 was released on Friday 8th May 2010.This isn't just a simple update as there are some great new features included.

Download the SDK at: Download SDK

This version of the SDK includes what is being called the Advanced Developer Extensions, this means that you'll be able to interact with the CRM data more simply, including using LINQ query expressions.

Further details, and walkthrough can be found on the Microsoft CRM Team Blog.