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

trigger related issue
Hi,
I want to copy one value from child obj to parent obj.
trigger Copyleadvaluetoacc on Lead (after insert, after update) {
List<Id> accIds = new List<Id>();
List<Account> accounts = new List<Account>();
for(Lead L : trigger.new){
accIds.add(L.Id);
}
for(Account a : [SELECT Id, Lead_Status__c FROM Account WHERE Id IN :accIds]){
for(Lead ld: trigger.new){
a.Lead_Status__c=ld.Status;
accounts.add(a);
}
}
if(accounts.size()>0){
Update accounts;
}
But it is not working.Please help
I want to copy one value from child obj to parent obj.
trigger Copyleadvaluetoacc on Lead (after insert, after update) {
List<Id> accIds = new List<Id>();
List<Account> accounts = new List<Account>();
for(Lead L : trigger.new){
accIds.add(L.Id);
}
for(Account a : [SELECT Id, Lead_Status__c FROM Account WHERE Id IN :accIds]){
for(Lead ld: trigger.new){
a.Lead_Status__c=ld.Status;
accounts.add(a);
}
}
if(accounts.size()>0){
Update accounts;
}
But it is not working.Please help
Thanks.
All Answers
I think this is something that can be solved simply using a process builder instead of trigger, below is the link to an implementation you can use as reference:
>> https://trailblazers.salesforce.com/answers?id=9063A000000DwewQAC
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Thanks.