You need to sign in to do that
Don't have an account?
pranavshah
Apex trigger for opportunity object
Hi All,
their is one requirement i have ..
i have 'Amount field' on opportunity needs to be entered whenever a opportunity is created related to a particular account once a opportunity is created ,then i want 'Total Opportunity Amount' field on Account object needs to be updated.
I want to write trigger for the same
How it will be done
I have written this much amount of code, but i am not able to go ahead..as i am on learning stage ..please help me out.
public class opportunityhandler
{
public void opportunityamount(list<opportunity> newopportunity)
{
set<String> setOppName=new set<String>();
for(opportunity opp:newopportunity)
{
setOppname.add(opp.Amount);
}
list<opportunity> opps= [select Name, Amount from opportunity where AccountId =:setOppname];
{
}
}
}
their is one requirement i have ..
i have 'Amount field' on opportunity needs to be entered whenever a opportunity is created related to a particular account once a opportunity is created ,then i want 'Total Opportunity Amount' field on Account object needs to be updated.
I want to write trigger for the same
How it will be done
I have written this much amount of code, but i am not able to go ahead..as i am on learning stage ..please help me out.
public class opportunityhandler
{
public void opportunityamount(list<opportunity> newopportunity)
{
set<String> setOppName=new set<String>();
for(opportunity opp:newopportunity)
{
setOppname.add(opp.Amount);
}
list<opportunity> opps= [select Name, Amount from opportunity where AccountId =:setOppname];
{
}
}
}
Please check once following code. use your field Total Opportunity Amount instead of Total_Count__c .
Hope this helps you!
Thanks
Varaprasad
@For Support: varaprasad4sfdc@gmail.com
Since you are at earning state I would like to recommend the use of Map and avoid nested for loop. @varaprasad code will work perfectly but we can improve more in term of performance.
Please mark this as the best answer and help the community grow...
--
Thanks,
Prashant