You need to sign in to do that
Don't have an account?
Swamy P R N
Hoe do i get converted LeadId in Opportunity
Hi Buddies,
I have a scenarion that, whenever lead is converted its creating an opportunity. Now i want to populate that leadid in opportunity.
or else
How can i find the opportunity is created from conversion of lead or it is created seperately in system?
I have a scenarion that, whenever lead is converted its creating an opportunity. Now i want to populate that leadid in opportunity.
or else
How can i find the opportunity is created from conversion of lead or it is created seperately in system?
trigger trigMapFields on Lead (before update) {
Map<Id,String> leadStatus = new Map<Id,String>(); // Map of the converted Contact ID and the Lead Status
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead.Status);
}
}
List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :leadStatus.keySet()];
for ( Contact c : conContacts) {
c.Type__c = leadStatus.get(c.Id);
}
update conContacts;
}
All Answers
This is very simple create a check box field in lead object and make check box default true.
And create a same type of field in opportunity and map both lead on opportunity fields by standard mapping.
Thats it when a lead is converted the check box on opportunity will be true .
If opportunity is created directly it will be false.
Thanks
Anil.B
but i don't want to create the fields as an extra..So is there any work around with standard configuration??
In Lead we have a API called " ConvertedOpportunityId " like that is any field in opportunity like "ConvertedLeadId " ??
Ther is no such type of field(ConvertedLeadId) in opportunity.
The only option is to create a new filed.
Thanks
Anil.B
We have CreatedOpportunityId field on Lead Object. Once the lead is converted than we will query on newly created opportunity than we will update Lead ID field(on opportunity).
I am also getting same issue ,if you got this solution ,Pls provide also.
Thank you,
Pramod kumar
trigger trigMapFields on Lead (before update) {
Map<Id,String> leadStatus = new Map<Id,String>(); // Map of the converted Contact ID and the Lead Status
for(Lead lead : Trigger.new) {
if (lead.IsConverted) {
leadStatus.put(lead.ConvertedContactId,lead.Status);
}
}
List<Contact> conContacts = [select Id from Contact WHERE Contact.Id IN :leadStatus.keySet()];
for ( Contact c : conContacts) {
c.Type__c = leadStatus.get(c.Id);
}
update conContacts;
}
option 1. create a lead Id field and map it to your text field in the opportunity.
option 2. use process builder on when lead is converted and converted opp Id <> '' - update opp-y related to the lead with the lead id value in your custom field
may be other options are also there.
in anyway you can not do a lookup as it will not work - if you only wanted to see which opp comes from a lead - use a report type "lead with converted lead information" or a similar one