function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
aa143aa143 

approval process based on editing value

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

    I am having a quote and i am having prices,quantities which i will get from pricebook prices which are editable.
    If at all while filling form price is modified(increased or decreased) then it must send for approval process.
    Then email will be send for approval.
    If it rejected or approved must be updated . 5.criterai are not met and the approval moves move to the next step. criterai are met and the assignd user approves the record, approval moves move to the next step.
Daniel B ProbertDaniel B Probert
you should be able to fire the approval process from a trigger or from a work flow

this would be the trigger(you need the approval process created already)
trigger OldValueCheck on Opportunity (before update) {
  for (Opportunity opp : Trigger.new) {
    // Access the "old" record by its ID in Trigger.oldMap
    Opportunity oldOpp = Trigger.oldMap.get(opp.Id);

    // Trigger.new records are conveniently the "new" versions!
    Boolean oldOppIsWon = oldOpp.StageName;
    Boolean newOppIsWon = opp.StageName;
    
    // Check that the field was changed to the correct value
    if (!oldOppIsWon != newOppIsWon) {
      Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
                req.setObjectId(Trigger.new[i].Id);
                Approval.ProcessResult result = Approval.process(req);
                System.debug('Submitted for approval successfully: '+result.isSuccess());
    }
  }
}

you might have to have a play about with it to get what you want but it should work in  theory..