I have a need to generate an approval request and then immediately approve it via Apex. This is being done purely for record keeping and to properly show that a user approved a record. For instance, this is the type of code I am looking to run (taken from Salesforce):

    // Insert an account
    Account a = new Account(Name='Test',annualRevenue=100.0);

    insert a;

    // Create an approval request for the account
    Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
    req1.setComments('Submitting request for approval.');

    // Submit the approval request for the account
    Approval.ProcessResult result = Approval.process(req1);

    // Approve the submitted request
    // First, get the ID of the newly created item
    List<Id> newWorkItemIds = result.getNewWorkitemIds();

    // Instantiate the new ProcessWorkitemRequest object and populate it
    Approval.ProcessWorkitemRequest req2 = new Approval.ProcessWorkitemRequest();
    req2.setComments('Approving request.');
    req2.setNextApproverIds(new Id[] {UserInfo.getUserId()});

    // Use the ID from the newly created item to specify the item to be worked

    // Submit the request for approval
    Approval.ProcessResult result2 =  Approval.process(req2);

Now, as with all approval processes, this will generate an email to the user. However, the user has already approved the request so that email is irrelevant. Is there a way to completely stop that email? I know we can override what is sent, but I just don't want to send anything. Does anyone have any ideas?

EDIT: For clarification, the use case for this would be something like:

  • User A has the Standard Sales Rep profile.
  • User B has the Sales Manager profile and is the manager of User A.
  • When User A creates a record of Custom_Object__c, that object is automatically submitted for approval to User B.
  • When User B Submits a record of Custom_Object__c, the system sees they have the proper profile and automatically submits and approves the record.

The issue is when User B does that, they get an email indicating that there is an item waiting for their approval even though that approval already occurred.

2 Answers 2


Is there a reason you are using a User as approver? Approver can also be a queue. What about creating a queue, no users, and assigning that as approver?

  • Wouldn't that say that the approver is the queue then? The goal is to get the Approval History to list the approval as the user taking the action. I will add some additional information to my question to give you a use case. Feb 6, 2013 at 18:16
  • No, you may assign to queue but "actual approver" will always be a human being (same as when you as SysAdmin decide to approve whatever you want because of "Modify All Data" eben though it was assigned to John Doe). To make a fake queue, without email address & approve might be not a bad idea. Check if people won't lose rights to modify the record though once owner is changed.
    – eyescream
    Feb 6, 2013 at 23:44
  • @eyescream has a good point about the owner changing. That isn't something I had considered. For now though, this does appear to be the best solution (it is better than just sending an email even though it is not needed). Hopefully Salesforce provides a way to just not send the email eventually. Feb 7, 2013 at 15:00
  • @Peter, if you assign an empty queue as the approver that will solve the email issue. But by what right will the user then be authorized to approve? Surely SF doesn't just let any user approve especially in such a case where the approver is the owner! If that were so, any user could approve anything they submitted for approval.
    – Marc
    Mar 18, 2013 at 19:19
  • I would have to test to be sure, but this is approval by Apex, right? So you would need to run the Apex as "without sharing" most likely in order that your Apex have the privileges to perform the approval on behalf of someone who otherwise would not have the perms.
    – pchittum
    Mar 19, 2013 at 8:36

We've had a similar requirement: don't send any approval request mail when a record is submitted for approval.

Since SalesForce does not let you prevent the standard email going to the approver we set the "Receive Approval Mails" to never on the user.

Side-effect and workaround is that you have to add a custom Email step to all approval processes where you do want an approval request email.

Another option which I've not explored is to define a custom email on the approval workflow (thereby overriding the standard mail) but to send the email to nowhere or some central bin.

You must log in to answer this question.

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