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

writing trigger to calculate current fiscal year revenue on account object
Hi,
I have been suffering with lack of logic from last couple of days.
i want to write a trigger on account object custom field which will calculate revenue for current fiscal yearYTD based on oppotunity amount.
once the current fiscal yearYTD gets changed again calculations start from next fiscal yearYTD.(that mean whatever value stored for last current fiscal yearYTD need to be override with urrent fiscal yearYTD)
Can somebody help me in figure out the best approach to get current fiscalYTD.
I hope i'm clear with my question.
Thanks in Advance
Thanks&Regards
Lakshman
I have been suffering with lack of logic from last couple of days.
i want to write a trigger on account object custom field which will calculate revenue for current fiscal yearYTD based on oppotunity amount.
once the current fiscal yearYTD gets changed again calculations start from next fiscal yearYTD.(that mean whatever value stored for last current fiscal yearYTD need to be override with urrent fiscal yearYTD)
Can somebody help me in figure out the best approach to get current fiscalYTD.
I hope i'm clear with my question.
Thanks in Advance
Thanks&Regards
Lakshman
Then,you need to do some operation so that the Trigger would re-fire again in Next fiscal year as you need to update the next fiscal year values too something like a scedulable class.
I would rather suggest you to use Schedulable class to do your operation in place of Trigger if you requirement is to update once in Fiscal year not real time.
Hope this helps!!
If this helps,please mark it as best answer to help others :)
Vinit is also on the right path, but I'd take it one step further. Vinit is correct that a Scheduled Job would help when the calendar year rolls over, but I would put most of my logic within Batch Apex, not the Scheduled Apex. Why you ask? Batch Apex has much higher governor limits than Scheduled Apex. If you have too many Accounts, the Scheduled apex might hit limits. With Batch, you most likely won't hit any limits (or not anytime soon anyway).
Let us know if it helps , please mark it as best answer to help others.
Thanks every one for your valuable suggestions.
@Shankwi: yes , u r correct calculations only happen when we any thing changed in records but aggregare functions lets you calculate without editing also.correct me if im wrong.using aggregate functions in soql will consider whole records for calculations.
@Vini_kumar: if we use THIS_FISCAL_YEAR in where clause its keep calculates the value.calculations wont happen when year changed.
here is my explanation for the my problem.
Think that 2014 is current fiscal YTD.thare is field called sum.when fiscal year started ,values should added to that sum field.think that sum is having value as 500.when 2014 is changed and fall into next fiscal year 2015, calculations should happen from first value.
Hope im clear with my question
Thanks&Regards
Lakshman