+ Start a Discussion
Amol PrachetaAmol Pracheta 

write a trigger on opportunity before insert and before update. Apply 10% discount on amount field before saving a record.

Andrew GAndrew G
reads like a homework task.  good luck.
Suraj Tripathi 47Suraj Tripathi 47

Hi Amol,

Please try this trigger  before update and before insert on Opportunity : 

public static void addDiscount(List<Opportunity> newOppList){
            for(Opportunity eachOpp : newOppList){
                eachOpp.Amount = eachOpp.Amount - eachOpp.Amount * (0.1);
            upsert newOppList;
        }catch(Exception e){
            System.debug('Error at line number '+e.getLineNumber()+'. '+e.getMessage());

Let me know if it solves your issue and mark it as the best answer.