function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
imishraimishra 

Converting Lead to Account and Contact only

Hi,

 

I have a multiselect picklist field with values A,B,C,D,E.

I want when i select A or B, it should create only account and contact but when i select C or D or E, it should create Account,Contact and Opportunity.

 

Please help me, its very urgent.

 

Thanks.

RiyaRiya

 

on the picklist onSelect event  u can have actionsupport .In the action support function have filter for the two type of picklist value .if u dont want opportuinty then setDoNotCreateOpportunity(True);

 

http://salesforce.stackexchange.com/questions/4756/convert-lead-through-apex-but-should-not-create-opportunity

 

 

 

imishraimishra

But i am using the standard page layout. How do i call the class?

@anilbathula@@anilbathula@

Hi

 

Write a after update trigger on the lead .

 

trigger test on Lead (after update) {
 for(Lead lead:Trigger.new) {
  if (Lead.IsConverted==true && (lead.picklist__c=='A'||lead.picklist__c=='b')){
  //do something
 }
else(Lead.IsConverted==true && lead.picklist__c=='c'){
//do something
} }
}

 

imishraimishra

Hi,

I have written the below code:

 

trigger test on Lead (after update) {
 for(Lead lead:Trigger.new) {
  if (Lead.IsConverted==true && (lead.Type_of_Contact__c=='Marketing' || lead.Type_of_Contact__c=='PR')){
      Database.LeadConvert lc1 = new database.LeadConvert();        
       lc1.setLeadId(lead.Id);        
       lc1.convertedStatus = 'Converted';        
       lc1.setDoNotCreateOpportunity(true);               
       Database.LeadConvertResult lcr1 = Database.convertLead(lc1);        
       System.assert(lcr1.isSuccess());
    }else{
       Database.LeadConvert lc1 = new database.LeadConvert();        
       lc1.setLeadId(lead.Id);        
       lc1.convertedStatus = 'Converted';        
       lc1.setDoNotCreateOpportunity(false);               
       Database.LeadConvertResult lcr1 = Database.convertLead(lc1);        
       System.assert(lcr1.isSuccess());
     }
 
    }
}

 

Still its not working. Where should i call this trigger? Will it work for the standard convert button?

Can u plz tell wat m i missing in this?