Her you want to run trigger on specific time. So you need to scheduler.
For this write a class which implements a scheduler interface and write code such that any insert or update operation on particular object on which you have written a trigger.
Now go to Apex Class link and click on Schedule Apex button and select the class you have implements the scheduler and schedule it as you required.
Here is an example for scheduler class
Global with sharing class ScheduleClassname implements Schedulable {
Global void execute (SchedulableContext SC)
{
// Required Logic to fire trigget
}
}
ok, let's say i import accounts and contacts into SFDC. for instance, for address field, i have another custom field that copy from all the standard address field values. i can loop it. however, there is limitation to the loop, right? i hit limitation issues while looping till 5k records previously. how can i avoid such issue? say i have 10k accounts and i want to loop through each of them. any way to do so? thanks
ok. i have 1 trigger that copies all address standard field into a custom field when account is created/updated.
however, if i import the account - meaning the account is not created/updated, the trigger will not fire.
so, i would like to write a class that can execute the trigger by scheduling it to run at 12am each day.
is this possible?
another issue is, whenever i loop through account sets, whenever it hits 5k records, i get the over limit issue. so in the above case, i will need to loop through. it will throw the same error. is there a way to avoid it?
Yes, you can execute trigger from Apex Class.
Her you want to run trigger on specific time. So you need to scheduler.
For this write a class which implements a scheduler interface and write code such that any insert or update operation on particular object on which you have written a trigger.
Now go to Apex Class link and click on Schedule Apex button and select the class you have implements the scheduler and schedule it as you required.
Here is an example for scheduler class
ok, let's say i import accounts and contacts into SFDC. for instance, for address field, i have another custom field that copy from all the standard address field values. i can loop it. however, there is limitation to the loop, right? i hit limitation issues while looping till 5k records previously. how can i avoid such issue? say i have 10k accounts and i want to loop through each of them. any way to do so? thanks
Hi,
I didn't understand clearly what you are looking for.
But If you have more number or records use Batch Apex to avoid this and make batch size as per you required.
ok. i have 1 trigger that copies all address standard field into a custom field when account is created/updated.
however, if i import the account - meaning the account is not created/updated, the trigger will not fire.
so, i would like to write a class that can execute the trigger by scheduling it to run at 12am each day.
is this possible?
another issue is, whenever i loop through account sets, whenever it hits 5k records, i get the over limit issue. so in the above case, i will need to loop through. it will throw the same error. is there a way to avoid it?