1

I am new to Apex but thanks to the community I learn quickly. I have been looking for a solution to my problem for a few days that is why I am talking to you.

i want to run a custom quick action in "opportunity" from my apex batch, but i don't know how to get it into my batch or run it.

ideally the user does not need to click on this action, because it will happen automatically every week.

Can someone help me?

1 Answer 1

4

You can execute Quick Actions in Apex code via the QuickAction class.

Specifically, you call the static method performQuickAction() with an instance of QuickActionRequest that defines what you want to do. Here's an example from the documentation that shows how to do this:

QuickAction.QuickActionRequest req = new QuickAction.QuickActionRequest();
// Some quick action name
req.quickActionName = Schema.Account.QuickAction.AccountCreateContact; 

// Define a record for the quick action to create
Contact c = new Contact(); 
c.lastname = 'last name';
req.record = c; 

// Provide the context ID (or parent ID). In this case, it is an Account record.
req.contextid = '001xx000003DGcO'; 

QuickAction.QuickActionResult res = QuickAction.performQuickAction(req);

You'll provide a "context Id" (the record in reference to which the Quick Action is being executed), a record representing what the user would input in the UI, and the name of the desired Quick Action.

Of course, you won't be able to execute Quick Actions that require user interaction, such as Visualforce or Lightning Component-based actions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .