1

I am new to salesforce. I want to write an approval process.

  1. I am having a quote and I am having prices,quantities which I will get from pricebook prices which are editable.
  2. If at all while filling form price is modified(increased or decreased) then it must send for approval process.
  3. Then email will be send for approval.
  4. If it rejected or approved must be updated.
  5. Criteria are not met and the approval moves move to the next step. Criteria are met and the assigned user approves the record, approval moves move to the next step.

1 Answer 1

2

You should start by reading the available documentation on approval processes. Here is one starting point for that. Most of the logic is built into the approval process itself.

At some point it may be possible to automatically Submit For Approval Through Workflow Rules, but for now if you want that to be done automatically you have to write a bit of Apex code. Here is one (oldish) example of how to do that Automating Salesforce Approval Processes with Apex Triggers. Your trigger will instead be looking for changes to the quote price field:

trigger QuoteSubmitForApproval on Quote (after update) {
    Approval.ProcessSubmitRequest[] requests = Approval.ProcessSubmitRequest[] {};
    for (Quote q : Trigger.new) {
        Quote old = Trigger.oldMap.get(q.Id);
        if (q.Price != old.Price) {
            Approval.ProcessSubmitRequest request = new Approval.ProcessSubmitRequest();
            request.setComments('Submitted for approval. Please approve.');
            request.setObjectId(q.Id);
            requests.add(request);
        }
    }
    if (requests.size() > 0) {
        Approval.process(requests);
    }
}

You must log in to answer this question.

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