enter image description hereI need your help.I am parsing approval email response via email service.Everything is working as expected. But When I am sending any record for approval and then Assigned approver is replying through email as Approve or Approved, the record got approved but in Approval history section my name is coming as actual approver all the time.I tried many things but it's not working.How to change actual approver based on who is replying to that email.I see some people faced same issue but I didnt see any work around.Please see attached for more details

code snippet

 if(firstLine.containsIgnoreCase('Approved') || firstLine.containsIgnoreCase('Approve') || firstLine.containsIgnoreCase('OKAY') || firstLine.containsIgnoreCase('YES')) {
public void approvalreq(){
    List<ProcessInstance> pi =[SELECT Id FROM ProcessInstance WHERE TargetObjectId=:recordid];
    List<ProcessInstanceWorkitem> piw =[SELECT Id,ActorId,ProcessInstanceId FROM ProcessInstanceWorkitem WHERE ProcessInstanceId=:pi[0].Id];
        Approval.ProcessWorkitemRequest req2 =new Approval.ProcessWorkitemRequest();

        Approval.ProcessResult result2 =Approval.process(req2);     
  • Can you paste the code for what you are trying to do? Dec 2, 2016 at 18:24
  • Hi Ritika, I have updated question accordingly.
    – Ayush
    Dec 4, 2016 at 6:42

1 Answer 1


The standard functionality to allow a user to approve by responding to an email is called email approval response.

By using the standard functionality, you don't need to set up your own email service to handle the emails or parse the response for "approved"-like keywords, and the user sends the email will be recorded as the approver in the approval process history.

  • Hi Martin I need to parse additional keywords also like Okay or I am Okay. Dat's why I am using email service
    – Ayush
    Dec 4, 2016 at 6:38
  • @Ayush no matter who sends the email, the inbound email handler will be run with the admin as the context user and all actions will be recorded as being done by the admin.
    – martin
    Dec 5, 2016 at 0:29
  • 1
    clarification -- email service running user is the context user defined in the metadata, not necessarily an admin; more likely a headless user
    – cropredy
    Dec 5, 2016 at 2:52
  • good point, the context user doesn't have to be an admin @cropredy
    – martin
    Dec 5, 2016 at 3:32
  • @ Martin @ Cropredy - That means in approval history actual approver will be a context user ? We can't set that to user that is replying to that email ,will be a actual approver?
    – Ayush
    Dec 5, 2016 at 7:54

You must log in to answer this question.

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