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

Trigger to fetch last 7 yrs records
I am new to write trigger. how to write a trigger to retrieve last 7 yrs old data and have to purge the data? If any one have the code please share. It will be very helpful for me.
here is an example query
SELECT Id FROM Account WHERE CreatedDate > LAST_N_YEARS:7
query whatever the fields you want !
What type of operation you want to do on last seven year data, do any field needs to be updated ? Can you please tell your use case?
If you have any code please share.
please give the exact requirement
1.Go to account record
2.If “Account status” = CANCELLED/PAY OR CANCELLED/SUSPEND
3.The field in account “Cancel date”= True
4.Calculate seven years from the ‘Cancel Date”
5. The some address and phone field should be null