Wednesday, November 11, 2009

Issues with deleting a picklist option from a Picklist attribute

CRM allows you to add/update/delete the picklist options of a picklist attribute. However, like most other contact managers that store the text/reference of the deleted picklist option in the records where it had been used, CRM does not store the reference. It differs in this regard. Once a picklist option has been deleted, all existing records that had used this value would be reset to “Default Value”.

While checking out the picklist option sequencing in detail to explain it to our customer we found that CRM by default will always bring back the value of the deleted option.

Here we take an example of Contact record and “Lead Source” picklist attribute.

1. We have added a pick list value with name “Test” in lead source picklist.

2. Now we have selected the test option in a contact record.

3. Now we go ahead and delete the “Test” option from “Lead Source”..

4. If you go back to the contact record that had this value assigned to it, it would now have been reset to “Default Value”


Now unless you save this record, it would automatically get the next option that you add with the same “Value”.

Another point worth mentioning is that if you had deleted one of the picklist options and published the customizations, the next time you add a new option to this picklist it would bring back the value of the deleted option. The value is editable in CRM 4.0 so make sure you change this value unless you were adding this as a replacement to the earlier deleted option.


Now we have deleted the test and publish the entity.

In below screen shot we are adding a another picklist option “Test123”, it will bring up the same value as that of “Test” the deleted option.



Now even if we edit the value and set it to say 200002, any further options that you add do not increment automatically to use the next sequence number i.e 200003 but rather would still bring up 200000 as the value by default for every new option that you add hence forth.

I am not sure if this is a feature or a bug, but I would rather have preferred it remember the last sequence number assigned and increment it from there on.

Monday, October 26, 2009

How to Increase the Tab limit in CRM Forms

By default the max number of tabs allowed in CRM Form is 8.

The max tab limit is defined in JavaScript of formeditor.aspx. This page can be found at the following location “\Microsoft Dynamics CRM\CRMWeb\Tools\FormEditor”.

You can change the count specified in the _iMaxTabs to increase the count as shown in the below screenshot.



Note: This is an unsupported change and it could be overwritten if you install Rollups for CRM.

Sunday, October 18, 2009

Global Functions/Variables available in Dynamics CRM

Global Functions:
There are various global functions which provide information about the client system.


IsOnline: This will return if the form has been opened from an Online or Offline system. This could be helpful if you would want a particular feature to be made available in a specific mode only.

Example:
if (IsOnline())
{
alert("You are working online");
}

These above are available through scripting. If you would like to check this in your server side app, you need to add reference to the Microsoft.Crm.Outlook.Sdk
assembly. The assembly contains a class named CrmOutlookService that can be used to check the status of the Outlook client.

IsCrmClientLoaded: This will return if the Microsoft Dynamics CRM for Outlook client has been loaded by Microsoft Outlook

IsCrmClientOffline: This will return true if Microsoft Dynamics CRM for Outlook with offline Access is currently in offline mode

GenerateAuthenticationHeader:
When you call webservice through scripting, you need to pass the authentication information along with the SOAP header. This function returns the appropriate Microsoft Dynamics CRM authentication header based on each deployment type: on-premise, Internet-facing deployment (IFD), or Microsoft Dynamics CRM Online.

Example:

var soapBody = "<soap:Body>"+
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/"+
"WebServices'>"+
"<Request xsi:type='WhoAmIRequest' />"+
"</Execute> </soap:Body>";
var soapXml = "<soap:Envelope " +
"xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' "+
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "+
"xmlns:xsd='http://www.w3.org/2001/XMLSchema'>";
soapXml += GenerateAuthenticationHeader();
soapXml += soapBody;
soapXml += "</soap:Envelope>";

PrependOrgName: The CRM URL by default adds the CRM Organization name when you browse CRM. It is important that if you are displaying a custom page in an IFRAME, the path to the page should also include the current Organization name. This function automatically determines the current organization name and adds it to generate the URL specific to the current organization.

Example:

var url = prependOrgName("/isv/app/myapp.aspx");
results: If you were logged into Contoso organization “/Contoso/isv/app/myapp.aspx”

Global Variables:
Some of the Global variables that can really come in handy are
1. SERVER_URL: This will return the base Server URL.
2. ORG_UNIQUE_NAME: This will return the unique text value of the organizations name. This is the same value to you also receive in custom forms if you set the PassParams to be true.



Tuesday, October 13, 2009

How to edit the list of entities displayed in the Look for picklist in Lookup window

The regarding lookup windows generally displays a list of all entities that can be associated with an activity. Quite often this feature becomes quite an issue with the users always having to select the appropriate entity from the list before applying the search. The longer the list of entities the more time consuming it is to search using the lookup window.

It would be a boon to have only a selected few listed that you use and do away with the rest. Well this is not available for customization through the CRM customization area. But it could be done with a couple of lines of script added to the onload of the form to manipulate the default properties of a lookup control to get the desired results.

For better understanding of how this works, it would be good to check the source of one of the CRM form that has a lookup control. In our example we are using the source of the Email form. Here when you search for regardingobjectid, you will find the “Lookup Types”, “Lookup Type names” ,”Lookup Type Icons” and “default type” properties of the Lookup control being set.



This provides the list of the entities that shall be displayed in the Look for entity list. To edit this to set your specific list of entities to show up in the Look for section you need to set these properties appropriately through scripting.

//Give the entity type code that you want in below script we want to show account, contact, contract and order in the list //codes
crmForm.all.regardingobjectid.lookuptypes = "1,2,1010,1088";

//Make sure you set the path of the entity images correctly for the list specified above. If you notice it is generally in the form of /imgs_ico_16_
crmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif: :/_imgs/ico_16_1010.gif : :/_imgs/ico_16_1088.gif ";

//The below script is to set default entity in the multiple entity lookup. Here we set the default entity to be contact. If you want contract then write 1010 in place of 2 in //below script
crmForm.all.regardingobjectid.defaulttype = "2";

You need to add the above 3 lines of code in the onload event of the email form and publish it. Next time the lookup window for regarding will only list the 4 entities listed above.

Friday, October 9, 2009

Using IE Developer tool to extract information from CRM forms.

CRM forms use lots of stylesheets to design their forms. It can be a very tough job to be able to design a custom form with the same look as that of standard CRM Forms. IE developer tool can be of great help in getting you closer to be being able to design similar looking forms.

The tool is made available by Microsoft and it help you to review the properties and stylesheet of specific element of the pages being displayed in your IE browser.

Once you install the tool it would be available on the IE standard toolbar as shown below.

Clicking on this button will show up the tool IDE with all the information. It is more organized way of what we get after view source.


If need to know properties (id/stylesheet info) of any field, area, left nav on form then choose select element option


Now select your field/region/area and its details shall be displayed like the color, id, css class names etc…

For the images you could get the control source

To get the URL of the left nav options

Stylesheet classes applied