You need to sign in to do that
Don't have an account?
Tom Ebenhoch
Auto Create Opportunity if Account Exists
So we are in the process of setting up a "Buy Now" function on our website and I have an existing apex class and workflow process that will auto convert the "buy now" leads and creates an account and opportunity. My question is, how can I set it up that if the company account already exists in our instance, that an opportunity will be automatically created?
This is the apex class that I have in place now, I would like it to be able to look up if an account already exists in our instance and then create just an opportunity if so.
This is the apex class that I have in place now, I would like it to be able to look up if an account already exists in our instance and then create just an opportunity if so.
Public class AutoConvertLeads { @InvocableMethod public static void LeadAssign(List<Id> LeadIds) { LeadStatus CLeadStatus= [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true Limit 1]; List<Database.LeadConvert> MassLeadconvert = new List<Database.LeadConvert>(); for(id currentlead: LeadIds){ Database.LeadConvert Leadconvert = new Database.LeadConvert(); Leadconvert.setLeadId(currentlead); Leadconvert.setConvertedStatus(CLeadStatus.MasterLabel); MassLeadconvert.add(Leadconvert); } if (!MassLeadconvert.isEmpty()) { List<Database.LeadConvertResult> lcr = Database.convertLead(MassLeadconvert); } } }
-Rajiv
In rare cases, system may be designed to automatically merge Leads with existing accounts, and in all such cases the rules will be very cleary defined - Name, Email and/or a few other fields that could unambiguously identify a duplicate.
Hope this information helps.
-Rajiv
-Rajiv