global class AccountBatch implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC){
String query = 'SELECT Id, Name, Industry FROM Account';
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<Account> accList){
for(Account acc : accList){
acc.Industry = 'Banking';
}
update accList;
}
global void finish(Database.BatchableContext BC) {
}
}
Schedulable Class:
global class AccountBatchScheduled implements Schedulable {
global void execute(SchedulableContext sc) {
AccountBatch objBatch = new AccountBatch();
Database.executebatch(objBatch);
}
}
Test Class:
@isTest
private class AccountBatchScheduledTest{
static testmethod void schedulerTest(){
String cronexpression = '0 0 0 15 3 ? *';
Account acc = new Account();
acc.Name = 'Test Account';
Insert acc;
Test.startTest();
String jobId = System.schedule('ScheduleBatchApexClass', cronexpression, new AccountBatchScheduled());
CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
System.assertEquals(cronexpression, ct.CronExpression);
System.assertEquals(0, ct.TimesTriggered);
Test.stopTest();
}
}
Product object is a catalog of items or services that your organization sells.
A product may contain one or more different sets of prices (PriceBookEntry).
Products are represented by Standard Object – Product2.
Pricebook:
Pricebook object store a list of products and services that your organization sells.
Each organization has one standard price book that defines the standard or generic list price for each product or service.
An organization can have multiple custom price books that can be used for specialized purposes, such as a discount price book, price books for different channels or markets, price books for select accounts or opportunities, and so on.
For some organizations, the standard price book might be the only price needed, but if you need to set up further price books, you can reference the standard price book when setting up list prices in custom price books.
PriceBooks are represented by Standard Object – Pricebook2.
PricebookEntry:
PricebookEntry object is a product entry (an association between a Pricebook2 and Product2) in a pricebook.
This object allows products to be linked to standard price book or custom price book with a price for a given currency.
One price book entry is linked to only one product.
One price book entry can only appear in one pricebook.
One price book entry can be used in multiple line items. This also further creates flexibility for users to set their own prices.
PricebookEntry are represented by Standard Object – Pricebookentry
Data Model: PricebookEntry is the junction object between Product and Pricebook.
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject