Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. global class MerchandiseInventoryClass {
  2.  
  3.  
  4. webservice static void ConverttoInventory(String[] merchandise_id)
  5. {
  6. //Convert Merchandise collection into Inventory Collection...
  7.  
  8. Merchandise__c[] merchandise_collection = [SELECT ID,Author__c,Book_Title__c,Edition__c,Publisher__c,Total_Merchandise_QtyTotal_Qty__c,Status__c FROM Merchandise__c WHERE ID = :merchandise_id];
  9.  
  10.  
  11. Inventory__c i = new Inventory__c(); //Line 1
  12. List<Inventory__c> newInventory = new List<Inventory__c>();
  13. for(Merchandise__c m : merchandise_collection )
  14. {
  15. if(m.Status__c !='Fully Converted')
  16. {
  17. i.Author__c = m.Author__c ;
  18. i.Book_Title__c = m.Book_Title__c;
  19. i.Edition__c = m.Edition__c;
  20. i.Publisher__c = m.Publisher__c;
  21. i.Qty_Available__c = m.Total_Merchandise_QtyTotal_Qty__c;
  22. i.Merchandise__c = m.Id;
  23. m.Uninventoried_Qty__c = 0;
  24. m.Status__c = 'Fully Converted';
  25. newInventory.add(i);
  26. }
  27. }
  28. insert newInventory;
  29. update merchandise_collection;
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement