The Power Tools Script Library allows you to store apex scripts as salesforce records and run them at your convenience with a push of a button or schedule them to run at a timing of your choice. The results of your apex scripts are returned and you can optionally store these results (debug log results and user debug lines) as a related record.
About Script Libary
The Script Library uses an anonymous block - executeAnonymous(), for running Apex Scripts within Salesforce. Please note the following about running Scripts:
- Can include user-defined methods and exceptions.
- User-defined methods cannot include the keyword static.
- Scripts execute as the current/scheduled user and can fail to compile if the code violates the user's object and field-level permissions.
- It is recommended that the current/scheduled Script user has Author Apex permissions. Without this, there are limits to what can be executed within the Script.
Create a Script
From the Scripts Tab, click on New.
Script without a Schedule
Enter the Script Name, Description and Apex Code and
select the API Version that the Apex should run with.
Optionally select to Save Debug Logs. This is especially useful to view the results of scheduled scripts.
- Click Quick Save or Save and Return
Scheduled Scripts will run at their designated scheduled time as long as the Schedule Credentials have been entered and are valid.
Run a script manually from either:
The Script View page
The Script Edit page, after the Script Record has been saved
Displayed Script Results
After running a script the Script Results will be displayed, including the Script Results
, User Debug
and Debug Log
Saved Script Results
If Save Debug Logs
was selected on the Script record. A related Script Result
record will have been saved.
Click through to the record by clicking on the Script Result Number
. The Script Results will then be displayed.