Skip to content

Instantly share code, notes, and snippets.

@oakye
Created October 3, 2020 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oakye/32ffedaf4387b5183f22c923898dc841 to your computer and use it in GitHub Desktop.
Save oakye/32ffedaf4387b5183f22c923898dc841 to your computer and use it in GitHub Desktop.
Salesforce Apex concept training. This quickly adds records into a custom object.
// Use this in Execute Anonymous to create 5 Stock Itme records
// where the inventory on hand is less than the minimum stock level
List<Stock_Item__c> itemList = new List<Stock_Item__c>();
for (Integer i = 5; i < 10; i++) {
Stock_Item__c stockitem = new Stock_Item__c(
Description__c = 'An item of stock',
Item_Name__c = ('RAD Item ' + i),
List_Price__c = (14.99 + (i * 10)),
Minimum_Stock_Level__c = (50 + (i * 3)),
Stock_on_Hand__c = (20 + (i * 3))
);
itemList.add(stockitem);
}
insert itemList;
System.debug('Added ' + itemList);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment