Friday, August 6, 2010

Hiding Navigation Links & Controls in CRM

Hiding Navigation Links & Controls in CRM

Quick JavaScript solution for hiding both controls on a CRM page and links in the left-hand navigation page on an Entity Form.

The code below provides three functions that can be used to show/hide specific items on a CRM form:

var HIDE = 'none';
var SHOW = 'block';

// Function to show/hide CRM controls on a CRM form
// such as text boxes, lookups, pick-lists etc.
function SetCrmControlVisible(elementName, visibility)
{
SetElementVisible(elementName + '_c', visibility);
SetElementVisible(elementName + '_d', visibility);
}

// Fuction to show/hide specific elements on a CRM form
// such as the left-hand link items (More Addresses, Workflows
// and even custom ISV links
function SetElementVisible(elementId, visibility)
{
var elem = document.getElementById(elementId);
if (elem != null)
{
elem.style.display = visibility;
}
}

// Function to show/hide Navigation "Sections" in the left-hand
// links (Such as Sales, Marketing and Service)
function SetParentElementVisible(elementId, visibility)
{
var elem = document.getElementById(elementId);
if (elem != null && elem.parentElement != null)
{
elem.parentElement.style.display = visibility;
}
}

Add the above code to the Entity OnLoad (and ensure that you enable the event) and after that you are ready to show/hide elements on the CRM form.

By using the IE Developer toolbar, you can retrieve the id of the element to be hidden (note in IE 8 this come built in and is not a seperate download). Open an entity record (in this case a Contact), press CTRL+N to open it in a new window, and then select IE Developer Toolbar.

SetElementVisible('navOpps', HIDE);

To hide the entire “Sales” section from the left-hand navigation pane, I can once again find the id, but this time is of the parent item which would result in the following call to hide it:

SetParentElementVisible('_NA_SFA', HIDE);

Lastly, to hide an element on the form such as the “CRMAttribute” field
      
      SetCrmControlVisible('CRMAttribute', HIDE);

Thursday, August 5, 2010

IntelliSense for Sitemap and ISV.Config Editing in Visual Studio

IntelliSense for Sitemap and ISV.Config Editing in Visual Studio

In CRM we needs to edit Sitemap & ISV.config files most often.
To edit these files easily, visual studio providing intelligence for these XML files.
We have to configure intelligence for the visual studio......


Download the CRM 4.0 SDK. The files you will need are located in the schemas folder of the SDK.
Open the xml(sitemap/isv.config) file in Visual Studio.
Press F4 to bring up the properties dialog.



Copy the following lines into the Schemas value. Keep all as one line and be sure to update your paths to where your files are located:
"D:\CRMSDK 4.0\server\schemas\_root\SiteMapType.xsd"
"D:\CRMSDK 4.0\server\schemas\_resources\customizations.xsd"
"D:\CRMSDK 4.0\server\schemas\_resources\isv.config.xsd"


Now, when you start to edit your file, you will see the IntelliSense for your nodes and any malformed nodes will be highlighted.


Enjoy Editing Sitemap & ISV.config files using intelligence....

Tuesday, August 3, 2010

Using the Advanced Find for FetchXML builder

You can just open the Advanced find page and build the query as you like. Then run the query to see if it returns the data as you wish it should. If you are satisfied with the results and you want to know what query was sent into the CRM Framework, then press F11/ctr+N to get the address bar and enter this script and press enter.

***********************************************
javascript:alert(resultRender.FetchXml.value);
************************************************

If you get a warning about leaving the page, just press 'ok' and then the query which is sent to the framework opens up in a popup. Unfortunately you cannot select the text to copy and paste. But with Windows XP and Windows Server 2003 you can copy all text on the popup by clicking somewhere on the popup (not on the button "OK" ofcourse) and pressing ctrl+c. Now in notepad you can paste the text of the FetchXML.

Try this instead of the alert:

javascript:prompt("my query:", resultRender.FetchXml.value);

Easy way to Insert Huge Number of Values into CRM Picklist

Easily Inserting Huge Number of items into CRM Pick-list ( like Country/State pick-lists)

Follow the Following Steps

1.Create the attribute/picklist in the Microsoft CRM entity customization

2.Add at least one option

3.Export the entity as XML

4.go here: http://www.beatnik.at/picklist_for_mscrm.php

5.Enter the desired picklist values into the textbox

6.Click "Generate XML"

7.Open the XML-File that you exported in step (3) with WordPad or your favourite TextEditor (Notepad tends to have problems with encoding)

8.Search for the displayname or the schemaname of the attribute

9.Replace the options tag with the XML-String generated in (7).
It might look like that:


...


10.Save the XML-Customizations File

11.Import the File into MS CRM and publish

Set Requirement Level for CRM Attributes at Run-time using Java script

Set Requirement Level for CRM Attributes at Run-time using Java script


// Set field to not required
crmForm.SetFieldReqLevel("fieldname", 0);

// Set field to business required
crmForm.SetFieldReqLevel("fieldname", 1);

// Set field to business recommended
crmForm.SetFieldReqLevel("fieldname", 2);