Skip to content

Instantly share code, notes, and snippets.

@oakye
Created October 3, 2020 23:57
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/c5d58c46dc7304c44c6ea47df43767a3 to your computer and use it in GitHub Desktop.
Save oakye/c5d58c46dc7304c44c6ea47df43767a3 to your computer and use it in GitHub Desktop.
Salesforce Apex code to quickly create records into a custom object.
// Use this in Execute Anonymous to create 5 Stock Item records
// where the inventory on hand is greater than the minimum stock level
List<Stock_Item__c> itemList = new List<Stock_Item__c>();
for (Integer i = 0; i < 5; i++) {
Stock_Item__c stockitem = new Stock_Item__c(
Description__c = 'An item of stock',
Item_Name__c = ('RAD Item ' + i),
List_Price__c = (20.00 + (i * 10)),
Minimum_Stock_Level__c = (50 + (i * 10)),
Stock_on_Hand__c = (75 + (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