Add the #DF24 Developer Keynote to your agenda. Join us in-person on 9/19 at 2:30 p.m. PT or on Salesforce+ at 5 p.m. PT for the must-see session built just for developers.

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.

  1. From the Setup menu, select Developer Console.

  2. From the File menu, select New | Apex Class.

  3. Enter a name for the Apex Class.

  4. Click OK.

  5. In the Developer Console, replace the code that you see with this Apex class, then save your work.

  6. 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