Assign Users to Programs with a Schedulable Apex Class
Create a schedulable Apex class that bulk-assigns users to Enablement programs.
User Permissions Needed | |
---|---|
To create Apex classes: | Author Apex |
To assign or unassign programs: | Design and Deliver Enablement Programs OR Design and Deliver Enablement Lite Programs |
You can’t add Apex classes directly in production orgs. Only Developer Edition, trial, and sandbox orgs support direct Apex editing in Setup. To deploy Apex code in a production org, add it to a sandbox first, test it, and then promote it to production.
The Apex class calls the assignEnablementProgram invocable action.
-
From the Setup menu, select Developer Console.
-
From the File menu, select New | Apex Class.
-
Enter a name for the Apex Class.
-
Click OK.
-
In the Developer Console, replace the code that you see with this Apex class, then save your work.
-
To implement this schedulable class, execute this Apex code from Developer Console.
The assignEnablementProgram
invocable action counts against your org’s Bulk API 2.0 limits. To help accommodate these limits, this example shows a bulkified request.
See Also
- Salesforce Help: Considerations and Limitations for Enrolling Users in Enablement Programs
- Salesforce Developers: Apex Scheduler
- Trailhead: Asynchronous Apex