You need to sign in to do that
Don't have an account?
Jia Kang Won
how to add product(lookup) to Account with apex
I want a Apex code to add product from lookup list to my account.
Any idea??
Any idea??
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Since Product__C is a lookup field, you have set Product Id to that lookup field. BEfore that you need to query the required Product.
Try below sample code:
Note: This is just sample code to add Productwith a particular name to Account. The code should be bulkified as per the requirement.
Let us know if that helps you.
Best Regards,
BALAJI
All Answers
trigger mycustomize on Account (before insert, before update) {
for(Account acc : Trigger.new) {
acc.Type = 'Prospect';
//acc.Product__c= 'GenWatt Diesel 200kW';
}
}
Since Product__C is a lookup field, you have set Product Id to that lookup field. BEfore that you need to query the required Product.
Try below sample code:
Note: This is just sample code to add Productwith a particular name to Account. The code should be bulkified as per the requirement.
Let us know if that helps you.
Best Regards,
BALAJI
That is i want and work fine to me.
Appreciate fast respone and correct answer.
Thanks a lot, itwas help me
You can close the thread by marking Best Answer so that it can be helpful to someone else.
Have a Nice Day.