You need to sign in to do that
Don't have an account?

value not updating with trigger
Hi,
I have written one trigger.
trigger CopyleadvaluetoOpp on Opportunity (after insert) {
Set <String> OppotunityCustId = new Set <String> ();
for(Opportunity Opp : trigger.New)
{
OppotunityCustId.add(Opp.Customer_ID__c);
}
Map <String, Lead> matchingLeadMap = new Map <String, Lead> ();
for (Lead Ld : [Select Id,Status,Customer_Code__c From Lead Where Customer_Code__c IN :OppotunityCustId])
{
matchingLeadMap.put(Ld.Status, Ld);
}
List <Opportunity> opportunityToUpdate = new List <Opportunity> ();
for(Opportunity Opp : trigger.New)
{
if (matchingLeadMap.get(Opp.Customer_ID__c) != null)
{
// we found a mathing one
Opp.Lead_Exception__c = matchingLeadMap.get(Opp.Lead_Exception__c).Id;
// add it to a separate list and update it
opportunityToUpdate.add(Opp);
}
}
update OpportunityToUpdate;
}
but that Status form lead is not coping in opportunity lead exception field.Please help.
I have written one trigger.
trigger CopyleadvaluetoOpp on Opportunity (after insert) {
Set <String> OppotunityCustId = new Set <String> ();
for(Opportunity Opp : trigger.New)
{
OppotunityCustId.add(Opp.Customer_ID__c);
}
Map <String, Lead> matchingLeadMap = new Map <String, Lead> ();
for (Lead Ld : [Select Id,Status,Customer_Code__c From Lead Where Customer_Code__c IN :OppotunityCustId])
{
matchingLeadMap.put(Ld.Status, Ld);
}
List <Opportunity> opportunityToUpdate = new List <Opportunity> ();
for(Opportunity Opp : trigger.New)
{
if (matchingLeadMap.get(Opp.Customer_ID__c) != null)
{
// we found a mathing one
Opp.Lead_Exception__c = matchingLeadMap.get(Opp.Lead_Exception__c).Id;
// add it to a separate list and update it
opportunityToUpdate.add(Opp);
}
}
update OpportunityToUpdate;
}
but that Status form lead is not coping in opportunity lead exception field.Please help.
Can you elaborate on the scenario you are trying to address so that we can try the same in our orgs and search for the same,
Looking forward to your response.
Thanks.
No need of after trigger... There is no need of Update also...
Please use the code:
Thanks,
Mahrajan.C
This one is not working.Please help.