Skip to content

Instantly share code, notes, and snippets.

@pritaunk
Created October 26, 2017 19:29
Show Gist options
  • Save pritaunk/13b8ef47f76f4477d79739b235c20adb to your computer and use it in GitHub Desktop.
Save pritaunk/13b8ef47f76f4477d79739b235c20adb to your computer and use it in GitHub Desktop.
Requirement 2 RAD Presentation
//*REQUIREMENT 2*Before a Stock Item is deleted, make sure that the stock on
//hand is at 0. If it is not, Create a case so that someone is alerted.
//checking if the record is deleted
if(trigger.isdelete) {
for (stock_item__c stockdelete : trigger.old) //loop through all deleted items
{
if (stockdelete.Stock_on_Hand__c < 0) //check if stock on hand is not 0 then create a case to alert
{
case c = new case ();
c.subject = 'stock item being deleted';
c.OwnerId = '0050Y000001lnHx';
c.Description= 'Item_Name__c , stock_on_hand__c';
c.Status = 'new';
c.Origin = 'email';
//not sure how to get the record id for the
//record that's being deleted
insert c;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment