This is useful when you need to run a Anonymous APEX but similar to Batch Jobs but don't want to write a full APEX class and handle it ? This will help.
This uses a simple shell script where you provide the number of seconds it needs to sleep and number of time the APEX script needs to be executed and vola!! That's it.
-
A org is authenticated using the Salesforce CLI.
-
Download the repo using
Git Clone
or the shell script -
Give permission to execute the shell script using
chmod +x script.sh
for MAC or Linux for Windows using the PowershellSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
-
You need to have you APEX script that does the DML in the
./apex
folder. Please refer totest.apex
as sample. -
Update the Sheel variables with your prefrences
- Num of Runs
- Sleep Timer
- Org Alias
- Script Path ( This is relative to folder)
-
Execute the script using the terminal
./runapexfile.sh