Have you ever observed how powerful Advanced Find dialogue can be in the right hands? Well apart from looking at the customized result set and providing total control to filter the data Advanced Find can be used for some really cool tricks. Recently, I had to face a situation where I needed to turn Advanced Find into some bit simpler find by removing some functionalist and by adding a simple button on the Grid Toolbar.
I managed it somehow in few hours and thought to share it with you, just in case you also fall in the same trap some day. So here it goes, just note that, modifying Advanced Find is NOT at all supported and I DO NOT take any responsibility what so ever if you follow the steps I’ve mentioned below and end up with any kind of damage[mental\physical\financial\social\…].
Here are steps to add a button to advanced find window
1. Go to CRM Installation directory and navigate to \CRMWeb\AdvancedFind\. Mostly you will have to go to C:\Program Files\Microsoft Dynamics CRM\CRMWeb\AdvancedFind.
2. Take a back up of AdvFind.aspx.
3. Open AdvFind.aspx in any text editor. [Visual Studio is recommended though].
4. locate the first </form> tag.
5. Copy-paste the following line : <input type=”button” onclick=”Alert(‘Hey!!!… I am in Advanced Find Window…’)” value=”Click Me!!!” />
6. Save and Close the file.
7. Go to CRM and click on Advanced Find… Dialogue. You will see a long ugly button on top. Click on it to see the message.
This is a simple approach I’ve followed. There can be tons of things you can do. You can skin it to look like the real CRM buttons and then replace the alert message with some really useful and complex logic.
Anyways, I took it little further and added the following script and removed the button from the previous step.
<script language=”javascript” type=”text/javascript”>
function DoIt() {
var template = document.getElementById(“btnEditProperties”);
var newNode = document.createElement(template.tagName);
newNode.setAttribute(“class”, “ms-crm-Menu”);
newNode.setAttribute(“tabIndex”, “-1”);
newNode.setAttribute(“title”, “Visit Metrix…”);
var magic = “<SPAN class=ms-crm-Menu-Label><A class=ms-crm-Menu-Label tabIndex=-1 onclick=’return false;’ href=’javascript:onclick();’ target=_self><IMG class=ms-crm-Menu-ButtonFirst tabIndex=-1 alt=’Visit Metrix….’ src=’/_imgs/vieweditor/16_viewProps.gif’><SPAN class=ms-crm-MenuItem-TextRTL tabIndex=0>http:\\blog.crmxpress.net</SPAN></A></SPAN>”;
newNode.insertAdjacentHTML(“afterBegin”, magic);
template.parentNode.appendChild(newNode);
}
DoIt();
</script>
and I got this :
Also you might want to add a little delay in the execution of the script by using window.setTimeout method otherwise it will give error in case the grid is not loaded by the time script is called.