+ Start a Discussion
Vigneshwaran LoganathanVigneshwaran Loganathan 

Trigger for following case

Hi all,

I have given with a condition like Whenever Quantity ( in Inventory field ) goes below 10 Units i have to send mail for a person XXXXX.
Need help for this.
Best Answer chosen by Vigneshwaran Loganathan
Hi Vigneshwaran,

You can achive this using Workflow rule.Conddition would be like this
Evaluation Criteria: created, and every time it’s edited
PRIORVALUE(inventory_field) > 10 & inventory_field < 10.

If you still want to do this by Trigger then conddition will be as follow;

trigger SendEmail on inventory {
          for(InventoryObject io:Trigger.new)
                if(io.quantity <10 && Trigger.oldmap.get(io.id).quantity>10) {

                          //code for sending email