Home > MS CRM 4.0 > Default value for Lookup field

Default value for Lookup field


 
In my current project i got an requirement from the client asking to set default account for cases when the Case is created.Because the customer for all the cases is my client itself.So they don’t want to select each and every time.To set default lookup value there is no need to know the guid of the guid of the entity instance until unless there won’t be any duplicate name.
 
Below is the code that does this magic.
 
//it sets default account for Case
if(crmForm.FormType == 1)
{
var LookupField =  crmForm.all.customerid;
LookupField .AutoResolve = 1;
LookupField .SetFocus();
var accountDiv = crmForm.all.customerid.parentElement.previousSibling.getElementsByTagName("DIV")[0];
accountDiv .innerText = "PETA";
LookupField.Lookup(true, true, accountDiv .innerText , true);
 crmForm.all.title.SetFocus();
}
 
in the above sample code "PETA" is the account name thats is set as default lookup value in my case CRM form.
Advertisements
Categories: MS CRM 4.0
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: