You need to sign in to do that
Don't have an account?
sfdcianp
After Insert trigger on different objects
I am on contract object and i have a lookup for the account object , when selecting the particular account and giving a name to the contract then if i click on save then on that particular account a text field need to be updated with the name of the contract..
please help me in finding a solution for this trigger
Thanks in advance
Hi, Try this trigger
trigger UpdateAccount on Contract (after insert) {
list<Account> accList = new list<Account>();
for(Contract contract : trigger.new) {
if(Contract.AccountId != null) {
Account account = new Account(Id =Contract.AccountId);
if(contract.name != NULL){
account.YourTextField__c = contract.name;
accList.add(account);
}
}
}
if(accList.size()>0){
update accList;
}
}
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
All Answers
Hi, Try this trigger
trigger UpdateAccount on Contract (after insert) {
list<Account> accList = new list<Account>();
for(Contract contract : trigger.new) {
if(Contract.AccountId != null) {
Account account = new Account(Id =Contract.AccountId);
if(contract.name != NULL){
account.YourTextField__c = contract.name;
accList.add(account);
}
}
}
if(accList.size()>0){
update accList;
}
}
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks