On of my colleague had a requirement of restricting ConvertLead based on a pick-list in lead form (restrict to convert it to account\contact based on pick-list value). Finally event.Mode did the trick for me to achieve it.
You can obtain the values in ConvertLead dialog box by tracing its event.Mode value (=16). Below is the code sample for reference.
Screenshot
JavaScript Code:
OnSave Event
if(event.Mode == 16) //Event when Lead is Qualified.
{
var createAccount = crmFormSubmit.qlCreateAccount.value;
var createContact = crmFormSubmit.qlCreateContact.value;
var customerType = crmForm.all.new_type.DataValue; //You can obtain lead for attribute values
if(customerType = 1 && createContact == 'true')
{
alert("Lead's customer type is Account, hence it cannot be converted into Contact.\nPlease uncheck Contact in ConvertLead dialog box and try again.");
event.returnValue = false;
return false;
}
else if(customerType = 2 && createContact == 'true')
{
alert("Lead's customer type is Contact, hence it cannot be converted into Account.\nPlease uncheck Account in ConvertLead dialog box and try again.");
event.returnValue = false;
return false;
}
}
Reference:
ObjectType = crmFormSubmit.crmFormSubmitObjectType.value
FormSecurity = crmFormSubmit.crmFormSubmitSecurity.value
Account (check/uncheck) = crmFormSubmit.qlCreateAccount.value
Contact (check/uncheck) = crmFormSubmit.qlCreateContact.value
Opportunity (check/uncheck) = crmFormSubmit.qlCreateOpportunity.value
Currency = crmFormSubmit.qlOppCurrencyId.value
ShowNewRecords (checkbox) = crmFormSubmit.qlShowNew.value
Customer type = crmFormSubmit.qlOpportunityParentType.value
Customer id = crmFormSubmit.qlOpportunityParentId.value
Status = crmFormSubmit.ulNewStatus.value
No comments:
Post a Comment