Guest User

Untitled

a guest
Dec 16th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static void onBeforeInsert(List newStockItems) {
  2.  
  3. //List for existing items
  4. List<Stock_Item__c> existingStockItems = [SELECT Item_Name__c FROM Stock_Item__c];
  5. for(Stock_Item__c esi : existingStockItems){
  6. String existingStockItemName = esi.Item_Name__c;
  7. }
  8. system.debug('Number of Existing Items Pre-Insert'+ existingStockItems.size() );
  9.  
  10. //List for new items
  11. List<Stock_Item__c> newStockItems = [SELECT Item_Name__c FROM Stock_Item__c];
  12. for (Stock_Item__c si : newStockItems){
  13. String newStockItemName = si.Item_Name__c;
  14. }
  15. system.debug('Number of New Stock Items'+ newStockItems.size() );
  16. }
  17.  
  18. //If there is already a Stock Item with that name, change the
  19. //name so that it is the name entered, plus the words “Duplicate Item”.
  20. //We have a process in place to check for these elsewhere.
Add Comment
Please, Sign In to add comment