public with sharing class MyApexClass {
@InvocableMethod(label='My Apex method'
description='A method to do something awesome'
category='Account')
public static void run(List ids){
List records = [SELECT Id, Name FROM Account where Id IN :ids];
// Do something with the accounts...
System.debug('Records to be processed: '+records.size());
}
}
"Use the with sharing or without sharing keywords on a class to specify whether sharing rules must be enforced. Use the inherited sharing keyword on a class to run the class in the sharing mode of the class that called it.""
See more at Using the with sharing, without sharing, and inherited sharing KeywordsClick on save.
Once created, click on add object, Select Account from the dropdown.
From the "Start the process" select "when a record is created or edited"
Click on Save and It will look like this:
Click on Add Criteria
Give a name for your criteria and select "No criteria, just execute the actions!"
Click on save and It will look like this:
Click Add Action
Select Action Type: Apex. Give an action name, in our case "run"
From "Set Apex Variables" click on "Add row"
Select "Ids"
Type: Field reference
And from "Value" select the Account ID
Select Account ID
Click on save and It will look like this: