I want to replace the save button with submit for approval in an edit page of record. So that every time a user tries to edit the record then it won't be saved right away rather it will be submitted for approval. Btw i am using standard salesforce page.

  • 1
    If you want to save their edits in a deferred way, and only commit them to the record once they are approved, then this is actually a fairly complicated request. I think you would need a separate approval object and a trigger. Perhaps someone will have a simpler recommendation, though. – Adrian Larson May 10 '16 at 15:39

You can't replace the "Save" button like that. If you absolutely need something that automatically sends a record for approval, I recommend you write a trigger that manually does that on any save.

If you follow the sample in this link you will be able to see how it's done.

This snippet will prove particularly useful

    // Create an approval request for the object
    Approval.ProcessSubmitRequest req1 = new Approval.ProcessSubmitRequest();
    req1.setComments('Submitting request for approval.');
    req1.setObjectId(*<Object ID>*);

    // Submit on behalf of a specific submitter
    req1.setSubmitterId(*<User Id>*);

    // Submit the record to specific process and skip the criteria evaluation

    // Submit the approval request for the object
    Approval.ProcessResult result = Approval.process(req1);
  • Hey Sebastian, I know you know better than to post a Link Only Answer. :) Can you include some content? – Adrian Larson May 10 '16 at 15:36
  • It's pure code.... didn't think it was completely relevant.... but I can eat my own dog poo and do that. :D – Sebastian Kessel May 10 '16 at 15:36
  • 1
    Yeah, the point is just that links can break, so that content could be lost entirely. Especially with SF documentation it seems. – Adrian Larson May 10 '16 at 15:37
  • I know, I know... I should've known better and got lazy. :) – Sebastian Kessel May 10 '16 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.