CRM news and views from Simon Jackson

Sunday, February 07, 2010

CRM 4 Multi Entity Type Lookup

Create a single lookup on a CRM form that allows the user to select from multiple entity types. Download these two entities to see this in action.



The code is a class that you can implement, so it really should be easy to use. To use the class do the following steps:

On the entity that requires the multi entity type lookup:


  1. Add a N:1 relationship for each entity type that you want in the lookup.

  2. Add the look ups to the form, add one where you want the Multi Entity Type and the others to tab that we will hide from the user.


  3. In the onload paste in the class at the top:

  4. Call the class to setup the lookup



  5. Call the onsave method


  6. Please let me know if you find this useful by posting a comment.

Labels: ,

Adding a browse button (html input file control) to a CRM form

Here's a quick example of how to put a browse button (html input file control) on a CRM form and then populate another field when it changed. Put this into your onload and update the field name 'new_filepath' in the inputF_onChange method to the name of the field that you would to be populated with the full path.

inputF = document.createElement('input');
inputF.type = 'file';
inputF.onchange = inputF_onChange;

tbl = crmForm.all.tab0.getElementsByTagName('table');
if (tbl && tbl[0]) tbl[0].parentNode.insertBefore(inputF, tbl[0]);


function  inputF_onChange() {
if (inputF && inputF.value)
crmForm.all.new_filepath.DataValue = inputF.value;
}

Here's a list the members exposed by the input type=file object.
http://msdn.microsoft.com/en-us/library/ms535263(VS.85).aspx

It should be noted that the above example will not work for IE8 as JavaScript can no longer read the full path from the value property.

As an alternative I would recommend trying a more supported method, for example, create an ISV page with the input file control and read the path server side and use javascript to populate the control on the parent CRM form.

Labels: ,

Sunday, August 31, 2008

Enable Jscript Intellisense for CRM by Leveraging Visual Studio 2008

The promise to have Jscript intellisence over the crm JScript object model has me sold
on the book "CRM as a Rapid Development Platform" (electronic version $49.99) by David Yack.

On David's site you can find a videocast demonstrating the benefit's of intellisence for Crm JScript and how to achieve it. Enable CRM JScript Intellisense

As far as I am aware you need to buy the book to obtain the code that helps you achieve the intellisence in VS 2008.

Labels: , ,

Friday, March 02, 2007

CRM Javascript

Michael Höhne a CRM MVP has collated a list of handy JavaScript snippets that are frequently requested in the Microsoft CRM newsgroups.

The folloing snippets are listed (as of 2-Mar-2007)
  • Replacing the content of an IFRAME
  • Adding additional values to duration fields
  • Changing the title of a CRM form
  • Changing the Link of a Ticker Symbol from MSN Money to Yahoo Finances
  • Counting the number of backslashes in a string
  • Changing the label of a field at runtime
  • Changing the color of a single option in a picklist
  • Opening a new window without the IE menu and status bars
  • Disabling a form at runtime
  • Automatically changing the value of a text field to capitals
  • Getting notified when the user selects a another tab on a form
  • The current record id
  • The current object type code
  • Initializing a date field with the current date
  • Changing the URL of an IFRAME at runtime
  • Displaying a picture in a CRM form, using a text field to store the data source
  • Changing the default lookup type
  • Calculating a date field based upon the selection of a picklist
  • Creating a new email when double-clicking a standard text field
  • Resetting a field value if validation fails
  • Inserting line breaks in a text area control
  • Hiding an entire row of a CRM form
http://www.stunnware.com/crm2/data/More%20JavaScript%20code.htm

Labels: ,