Testing Strategies for Developer
Jun12

Testing Strategies for Developer

Salesforce provides a framework for testing apex code. Testing is the key to successful software development. Before deploying apex code, try to cover as many lines of code as you can. At least 75% of your Apex code must be covered by unit tests else your code will not be deployed to production. Why Test? You should not write test classes by keeping in my mind just to cover 75% of your code but should always try to cover your entire code before deploying to production. Test provides assurance of functionality Test reduce cost of change Test encourage modular and reusable code Test help document expected behavior Test + Code = less likely produce the bug What to Test? Things that should happen to happen (Positive) : Positive testing is a way to test expected behaviour of code that you wrote is suppose to do. Things that should not happen to happen (Negative) : This is the hardest and important thing to test that verify if the error messages are correctly produced along with the positive working of test cases, within the limits cases. User Access : This is basically the manual testing, which we perform by seeing the aspect of end-user test is done when we think of user interaction. This type of test is done by hand via insert, update, delete and undelete the records. Exceptions : Exception testing tests expected behaviour of code when an user with restricted access to sObjects are used in code. Bulk Testing : This test comes in when a class, trigger or any apex code insert and update data in bulk. We need to test the class by creating more than one record in multiple scenarios. Test Structure Principles for Best Practices Principle #1  Use of Asserts : Assert is the method of System Class. It is an important method for test class which is used to check the expected result of test scenario. “A test without assert method isn’t a test, it’s code execution.” There are three in-built assert methods which are as follows: assert(condition, message) assertEquals(expected, actual, message) assertNotEquals(expected, actual, message) Every test method should include at least one assertion. Principle #2   Use startTest() and stopTest() startTest() methods are used to reset governor limits. The code between Test.startTest and Test.stopTest executes in fresh set of governor limits that means your setup code will not interfere and give you false positives (or negatives) surrounding governor limits. stopTest() method focuses on asynchronous code to complete. In general, one should follow these steps while writing test class: Create your test data Start the test Use that test data within your tested...

Read More
Salesforce App Builder Certification
Mar14

Salesforce App Builder Certification

The Salesforce Certified Platform App Builder exam is for them who want to grow in their skills and knowledge in designing, building, and also want to implement custom applications using the predeclared customization capabilities of the Force.com platform.   In June 2015, Salesforce University introduced the three new certifications: Salesforce Platform App Builder Platform Developer I Platform Developer II Salesforce University splitting the Developer track into declarative certification and two programmatic certifications. The Salesforce Platform App Builder certification is like to the Certified Force.com Developer credential. Here are some concepts for understanding to pass the exam: Design the Data model, user interface, business logic and security for custom applications Customize applications for mobile use Design reports and dashboards Deploy custom applications The Platform App Builder Exam is an only 90-minute exam. The exam contains  60 single or multi-select questions. The passing score is 63%, or 38 correctly answered questions. How to prepare for the Salesforce Platform App Builder Certification Exam   Review the concepts in the Platform App Builder Study Guide & Group Objectives by Their Weightings as given below:   Perform a Self Assessment on the objectives and ID Areas Needing Knowledge Improvement Increase Your Knowledge Building Applications with Force.com Part 1 Building Applications with Force.com Part 2 Grab a Personal Developer Org and Practice Those Concepts Familiarize yourself Mock Questions Daily Routine: Take Mock Exams and Study Notes   Tips The App Builder Exam is very broad but it does not go extreme depth, So you will need to have an overview of a lot Salesforce & Force.coms features. Make sure that go through each section in the study guide and revise accordingly. The social section is worth 3% of the exam so you can only expect 1 or 2 questions. Make sure that read other guides as well, each person has a different take on the exam and may provide different insights. The process of elimination is yours! If you can not work out which answer is right, try and work out which answer is wrong! To get more information about Platform Developer I. Click here ...

Read More
Salesforce Google Map Integration
Sep02

Salesforce Google Map Integration

Google Map Integration Integrating google maps into Salesforce                         Description of the requirement: Starting with description of the Project we have worked upon, there’s an app we created for searching and showing Account’s location on the Map and knowing a route map from one location to another location via some locations(Checkpoints).                            Solution we came with: For the requirement we used Google maps api which is in Javascript format. There are some predefined javascript functions used in the Google map api. We used Google Maps library whoz source is coming from a link i.e., “https://maps.google.com/maps/api/”.                                 There are several Javascript functions we used here which are as follows: Function to get the current location of the User by using the browser’s location. Get the current location of the User by using the browser’s location:                  var geocoder;            var map;            function initialize(){                geocoder = new google.maps.Geocoder();                    console.log(lon+’***latlon–‘+lat );                var latlng = new google.maps.LatLng(lat, lon);                console.log(‘***latlon–‘+latlng);                var myOptions = {                  zoom: 12,                  center: latlng,                  mapTypeId: ‘roadmap’ /* ,                  mapTypeId: google.maps.MapTypeId.TERRAIN */                }                                         map = new google.maps.Map(document.getElementById(“map”), myOptions);   Here we used “google.maps.Geocoder();” to access Google Maps API geocoding service.    We created an apex class method which will take Address of the Account as a string and will return a Geolocation for that address i.e., in Latitude and longitude of the string  address passed in the function as a parameter to it.   Suppose a string will be as shown below: public Account accObj{get;set;} // This is a getter setter method contains Account record. String address = accObj.BillingStreet+accObj.BillingCity+accObj.BillingPostalCode+accObj.BillingCountry;   Now we used the below method to get the Latitude & Longitude: Get the Latitude & Longitude: public static String getLatitudeLongitude(String address){        String location=”;         try{                Double latitude = null;                Double longitude = null;                            Http httpGetRequest = new Http();                HttpRequest httpReq = new HttpRequest();                system.debug(‘******Address—‘+address);                address=address.replaceAll(‘ ‘,’+’);                address = address.replace(‘\r\n’, ‘ ‘);                        address = address.replace(‘\n’, ‘ ‘);                        address = address.replace(‘\r’, ‘ ‘);                        system.debug(‘******After       Address—‘+address);       httpReq.setEndpoint(‘https://maps.googleapis.com/maps/api/geocode/json?key=’+key+’&address=’ +address + ‘&sensor=false’);                                                                                            //Authentication to google api            httpReq.setMethod(‘GET’);            httpReq.setTimeout(6000);            HttpResponse httpResponseAddress = httpGetRequest.send(httpReq);                system.debug(‘res body: ‘ + httpResponseAddress.getBody());                JSONParser parser = JSON.createParser(httpResponseAddress.getBody());                                    while...

Read More
Eclipse IDE
Jun15

Eclipse IDE

I am writing this blog out of my experience to share the key details of the different IDEs I have used while programming in Force.com environment. This might help an experienced or newbie developer in choosing the right IDE to code.My favorite and most probably every programmers most loved IDE. Eclipse is famous as a Java Integrated Development Environment (IDE). Salesforce You can easily combine language support and other features into any of our default packages, and the Eclipse marketplace allows for virtually unlimited customization and extension. Eclipse give a feel of traditional desktop based programming from developer end and in backend it saves all in Salesforce Cloud. Eclipse for Salesforce: To code apex in eclipse you have to first install force.com IDE in your eclipse in order to sync your local server with salesforce server. What force.com IDE can do : Customizable Folders Structure: No more limitations for files or folders structures. Now developers can organize them in whatever way they want. Apex Code Completion: Save time, improve the coding velocity, and avoid making mistakes with Code Completion functionality for Apex. Anonymous Apex Execution: Test new solutions, debug your code or work with your organization using the Anonymous Apex with all of the code editing features you’ve got used to. Quick Search of a Current Selection: Once you select any text in your code all its occurrences within the document will be highlighted and marked on the scrollbar automatically. Debug Logs: When debugging code you usually execute Anonymous Apex, perform some actions in the UI or start scheduled jobs which then produce lots of logs for you to go through. In most cases your actions would provide you whatever information you need pretty easily but sometimes you need only some specific logs – with very long duration, very small or very big logs, failed or succeeded logs and so on.                         Find and replace Find, preview, and replace text as you type in a file or across all your projects. Latest Features: Execute Apex Test Suites Enjoy Optimized Test Execution See Apex Test Results More Quickly Enabled code­ coverage highlighting in Apex classes Provided whitelist filtering for user and request­type debugging in the Apex Debugger Share Apex Debugger licenses among your sandbox orgs Enabled Eclipse’s Java development tools (JDT) icons for Apex variables in the Apex Debugger How To Install : These instructions show you how to install the Force.com IDE into your existing Eclipse distribution or upgrade from a previous version. Prerequisites: To install Force.com IDE you must have these requirements filled: 1. Java SE Development Kit (JDK) must be installed in the system in order to install Eclipse.(Download JDK) 2....

Read More
ATOM IDE
Jun06

ATOM IDE

The Atom Atom is a text editor that’s modern, approachable, yet hackable to the core—a tool you can customize to do anything but also use productively without ever touching a config file. What Atom IDE can do : Cross­ platform editing Atom works across operating systems. You can use it on OS X, Windows, or Linux. Built­in package manager Search for and install new packages or start creating your own—all from within Atom Smart auto completion Atom helps you write code faster with a smart, flexible autocomplete. File system browser Easily browse and open a single file, a whole project, or multiple projects in one window. Multiple panes Split your Atom interface into multiple panes to compare and edit code across files. Find and replace:  Find, preview, and replace text as you type in a file or across all your projects. Latest Features : Most Recently Used Tab Switching. Opening and Managing Files from the Tree View. Adding Project Folders from the Command Line. Keyup Keystroke Support in Keybinds. Crash Recovery Environment Per Window Packages Using Async Git Electron Update More Ways to Move Text Added the ability to update an Atom window’s environment from the terminal by executing the same command with an updated terminal environment. How To Install : To install Atom in your system got to httpss://atom.io link and click the windows installer button it will start your downloading. After downloading the setup install it in your system but in order to configure atom for salesforce first download github from httpss://desktop.github.com/ after downloading github install it as well in your system. That’s not it after installing Github you have to install Mavensmate­ app too to make the atom work for Salesforce. To download Mavensmate please follow this link httpss://desktop.github.com/. After all these apps are installed than configure atom to work for your system. Configuration : Open File > Setting… > +Install > Search for “MavensMate” > Install Or from Command Line : apm install MavensMate­Atom When you are working on salesforce please make sure that mavensmate is also running. Now to make changes in the settings. MavensMate > Settings > Global Settings And for Plugin setting: MavensMate > Settings > Plugin Settings  Create a Project : To create your first MavensMate for Atom project: 1.  Be sure to configure your mm_workspace: MavensMate menu > Settings > Global Settings 2. MavensMate > New Project To run MavensMate commands, use the Atom command palette (on OSX: command+shift+p) or use the  .MavensMate menu in...

Read More
Sublime Text
May23

Sublime Text

I am writing this blog out of my experience to share the key details of the different IDEs I have used while programming in Force.com environment. This might help an experienced or newbie developer in choosing the right IDE to code. Sublime Text is a sophisticated text editor for code, markup and prose. You’ll love the slick user interface, extraordinary features and amazing performance.We are familiar with the Force.com IDE which is based on the Eclipse platform which we use to code, compile, test, package and deploy Salesforce projects. Today we can look forward to another cool tool for Salesforce Developers – MavensMate. It is a powerful open source tool for building Force.com IDEs. It helps us to develop Salesforce applications easily regardless of the platform or text editor. Most of us are using the beloved Sublime Text for coding our projects. My favorite and most probably every programmers most loved IDE. Eclipse is famous as a Java Integrated Development Environment (IDE). Salesforce You can easily combine language support and other features into any of our default packages, and the Eclipse Marketplace allows for virtually unlimited customization and extension. Eclipse give a feel of traditional desktop based programming from developer end and in back end it saves all in Salesforce Cloud. Let’s see how to integrate MavensMate with Sublime Text to make it a powerful development environment like (or better than) the Force.com IDE. What Sublime Text can do Go to Anything Use Go to Anything to open files with only a few keystrokes, and instantly jump to symbols, lines or words. Triggered with Ctrl+P, it is possible to: Type part of a file name to open it. Type @ to jump to symbols, # to search within the file, and : to go to a line number. These shortcuts can be combined, so tp@rf may take you to a function read_file within a file text_parser.py. Similarly, tp:100 would take you to line 100 of the same file. Multiple Selections: Make ten changes at the same time, not one change ten times. Multiple selections allow you to interactively change many lines at once, rename variables with ease, and manipulate files faster than ever.Try pressing Ctrl+Shift+L to split the selection into lines and Ctrl+D to select the next occurrence of the selected word. To make multiple selections with the mouse, take a look at the Column Selection documentation. Command Pallette: The Command Palette holds infrequently used functionality, like sorting, changing the syntax and changing the indentation settings. With just a few keystrokes, you can search for what you want, without ever having to navigate through the menus or remember obscure key bindings.Show the Command Palette with Ctrl+Shift+P. Command-Pallette Distraction Free Mode: When you need to focus, Distraction Free Mode is...

Read More
Difference SLDS & Aura Components
Apr16

Difference SLDS & Aura Components

As we all know Lightning has been added to Salesforce very recently and it is the future of Salesforce. So lot of people who are new to Lightning but have the curiosity to learn it sometimes find it difficult to understand. I realised that the best way to start would be by describing what are the differences between Salesforce Lightning Design System and Salesforce Lightning Components Framework. So in this blog I will try to explain what are the major differences between Salesforce Lightning Design System and Salesforce Lightning Components Framework and hopefully it will clear out most of the doubts that a new developer is having regarding The Lightning Framework. Introduction to Salesforce Lightning Design System It is a css framework which is used for creating dynamic web apps.   By Using SLDS  We can make our apps responsive and can also provide  Look and feel  similar to the Lightning Experience. Steps to install the SLDS Unmanaged Packaged:For using SLDS in our Salesforce org. First We need to install the Latest Salesforce Lightning Design System unmanaged packaged as a static resource zip file.   Log into your Developer Org. Open the Salesforce Lightning Design System in a Separate window. Go to the Download Section. Click on the latest unmanaged package Now click on Install it. After Completing the above steps the package will get installed into your org.    Benefits of using Salesforce Lightning Design System: By using SLDS it’s easier to build apps which are responsive and also have the look and feel similar to Lightning Experience. It is compatible with multiple browsers like  Google Chrome, Latest Mozilla Firefox,   Latest  Safari Latest Internet Explorer 11 and above . It provides a robust grid system because of which It is easier to build responsive layouts that works elegantly across different screen sizes. The CSS is fully namespaced with the slds- prefix to avoid CSS conflicts. Introduction To Lightning Components Framework  It is built using Open Source Aura Framework. By Using Aura Framework We can build apps completely independent of the Data present in our Salesforce org. Benefits Of Lightning Components Framework : It provides an out-of-the-box set of components for building apps When we use Lightning Components  Framework We do not need to worry about the optimization of our apps for different devices as  Components take care of that by themselves. It uses the stateful client and stateless server architecture which uses  Javascript on client side for managing UI component metadata and Application data. It uses event Driven architecture which  enhances the decoupling  Between components. It supports the latest  browser technology such as HTML5,CSS3. Use Of Developer Console:The Developer Console provide us the tools which are Used...

Read More
Coding Genius (Trigger)
Jun11

Coding Genius (Trigger)

The following practice questions are for Salesforce developers who are new to salesforce and wish to solve some basic programming questions. Write a trigger 1. On Account create a default contact every time an account is created. What is Trigger Click here to learn more trigger Accounttir on Account (after insert) { list<contact> con = new list<contact>(); for(Account acc : trigger.new){ contact c = new contact(); c.LastName = acc.Name; c.AccountID = acc.ID; con.add(c); } insert con; } 2. Bulkify the above trigger to manage multiple record insertion. Trigger Bulkify Click here to learn more trigger Accounttir on Account (after insert) { list<contact> con = new list<contact>(); for(Account acc : trigger.new){ contact c = new contact(); c.LastName = acc.Name; c.AccountID = acc.ID; con.add(c); } insert con; } 3. On Opportunity to not let the user insert Opportunities with pass closed Date with following Message “Please enter a future Closed Date”. This can also be implemented by a validation rule but we want a Trigger to be written Click here to learn more trigger opportunitydate on Opportunity (before insert) { for(opportunity opp : trigger.new) { if(opp.Closedate<=Date.Today()){ opp.adderror(‘please eneter a future closed date’); } } } 4. On Product to setup default Pricebook entry in the “Standard Pricebook” as 1$. Product Schema Diagram Click here to learn more trigger Productupdate on Product2 (after insert) { list<PricebookEntry> pblist = new list<PricebookEntry>(); Pricebook2 pb=[Select id FROM Pricebook2 WHERE IsStandard=true]; for(Product2 pro:trigger.new){ PriceBookEntry pbe=new PriceBookEntry(); pbe.pricebook2id = pb.id; pbe.Unitprice=1; pbe.Product2Id=pro.id; pblist.add(pbe); } insert pblist; } 5. On Contact to update the Account Name field with contact Last Name, concatenated in the end. Example If “Tata” Account gets a contact “Ratan” created then Account Name field will be updated as “TataRatan”. Click here to learn more trigger updateAccname on Contact (after insert,before delete) { List<Account> accountlist=new List<Account>(); if(trigger.isInsert){ for(Contact con:[select Accountid,Account.Name,LastName from Contact WHERE Id IN:trigger.new]){ if(con.Account.Name!=null){ con.Account.Name+=con.LastName; accountlist.add(con.Account); } } }else if(trigger.isDelete){ for(Contact con : [select AccountId, Account.Name, LastName from Contact WHERE Id IN: trigger.old]){ system.debug(‘** contact –‘+con + ‘ *** Account –‘ + con.AccountId + ‘ *** Account Name — ‘+ con.Account.Name); con.Account.Name = con.Account.Name.replace(con.LastName,”); accountlist.add(con.Account); } } system.debug(‘*** ‘ +accountlist); update accountlist; } 6. Update the above trigger to delete the Last Name from the Account Company field when a Contact is deleted without deleting the other Last name. Example If “TataRatanNori” Account already have “Ratan” and “Nori” as its contacts and then contact “Ratan” gets deleted then Account Name field will be updated as “TataNori”. Click here to learn more trigger updateAccname on Contact (after insert,before delete) { List<Account> accountlist=new List<Account>(); if(trigger.isInsert){ for(Contact con:[select Accountid,Account.Name,LastName from Contact WHERE Id IN:trigger.new]){ if(con.Account.Name!=null){ con.Account.Name+=con.LastName; accountlist.add(con.Account); } }...

Read More
Coding Genius (Visual Force)
Jun10

Coding Genius (Visual Force)

The following practice questions are for Salesforce developers who are new to salesforce and wish to solve some basic programming questions. Develop the following Visualforce pages in your salesforce developer org. 1. Create a page that displays the detail page same as of the Account object along with its related lists Click here to learn more <apex:page standardController=”Account”> <apex:detail subject=”{!account.id}” relatedList=”true” title=”false”/> </apex:page> 2. Create a page that shows a datatable having 100 records. Click here to learn more <apex:page controller=”PageBlockTable” >   <apex:sectionHeader title=”Account List”/>   <apex:form >   <apex:dataTable value=”{!accountList}” var=”a”>   <apex:facet name=”header”>Account Name</apex:facet>   <apex:column value=”{!a.Name}”></apex:column>   </apex:dataTable>   </apex:form>   </apex:page>   public class PageBlockTable {   public list<Account> accountList{get;set;}   public PageBlockTable(){   accountList = new list<Account>();   accountList = [SELECT id,name FROM Account LIMIT 100];   }   } 3. Create a scrollable list of datatable that has 20 records. Click here to learn more <apex:page controller=”PageBlockTable” > <apex:sectionHeader title=”Account List”/> <apex:form > <apex:outputPanel layout=”block” style=”overflow:auto;width:850px;height:350px” > <apex:dataTable value=”{!accountList}” var=”a” > <apex:facet name=”header”>Account Name</apex:facet> <apex:column value=”{!a.Name}”></apex:column> </apex:dataTable> </apex:OutputPanel> </apex:form> </apex:page>   public class PageBlockTable {   public list<Account> accountList{get;set;} public PageBlockTable(){ accountList = new list<Account>(); accountList = [SELECT id,name FROM Account LIMIT 200]; } } 4. Develop the logic which shows/ hides the custom button “Test”. If the Opportunity>Stage = “Won” on an Opportunity record then the button should be displayed. Click here to learn more <apex:page standardController=”opportunity” extensions=”opportunityhide”> <apex:form > <apex:pageBlock > <div style=”display:none;”> dasdasdadda </div> <apex:outputPanel id=”abcd”> <apex:commandButton value=”test” rendered=”{!dadasda}”/> </apex:outputPanel> <apex:inputField value=”{!opportunity.stageName}”> <apex:actionSupport event=”onchange” action=”{!onCHeck}” rerender=”abcd” /> </apex:inputField> </apex:pageBlock> </apex:form> </apex:page>   public class opportunityhide { public boolean isTrue{get;set;} public boolean dadasda{get;set;} public Opportunity opp{get;set;} public opportunityhide(ApexPages.StandardController controller) { dadasda = false; opp =(opportunity) controller.getRecord(); } public void onCHeck(){ if(opp.stageName==’Closed Won’) { dadasda = true; } else { dadasda = false; } } } 5. Create a dataList that has 200 records and shows 10 records per page.It should have pagination with “Next” and “Previous” features in it.  Click here to learn more <apex:page standardController=”Account” recordSetVar=”Accounts” extensions=”AccountStandardSetController”> <apex:sectionHeader title=”Account List”/> <apex:form > <apex:dataTable value=”{!Accounts}” var=”a”>   <apex:facet name=”header”>Account Name</apex:facet> <apex:column value=”{!a.Name}”></apex:column> </apex:dataTable> <apex:panelGrid columns=”2″> <apex:commandLink action=”{!previous}”>Previous</apex:commandlink> <apex:commandLink action=”{!next}”>Next</apex:commandlink> </apex:panelGrid> </apex:form> </apex:page> public class AccountStandardSetController { public AccountStandardSetController(ApexPages.StandardSetController controller) { controller.setPageSize(20); } } 6. Create a page that has a text box and a datatable having column(Name, Phone, Postal Code and city) and in text box text is entered and on the basis of it the data block searches and shows the name column along with other columns.   Click here to learn more <apex:page controller=”DateBlock” > <apex:sectionHeader title=”Account List”/> <apex:form > <apex:inputText value=”{!searchstring}” label=”Input”/> <apex:commandButton value=”Search records” action=”{!search}”/> <apex:commandButton value=”Clear records” action=”{!clear}”/>...

Read More
Coding Genius (Batch Class )
Jun10

Coding Genius (Batch Class )

The following practice questions are for Salesforce developers who are new to Salesforce and wish to solve some basic programming questions. Using batch Apex classes, you can process records in batches asynchronously. If you have a large number of records to process, for example, for data cleansing or archiving, batch Apex is your solution. Each invocation of a batch class results in a job being placed on the Apex job queue for execution. Write or Schedule Apex Batch classes for the following. 1. Write an Apex Batch class in your Salesforce developer org to delete Accounts created in last 10 days. Click here to learn more global class AccountDelete implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query = ‘SELECT Id,CreatedDate FROM Account WHERE CreatedDate <= N_DAYS_AGO:10’; return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<Account> scope) { /*List <Account>acclist = new List<Account>(); for(Account acc:acclist){ //string test = acc.Name; acclist.add(acc); }*/ system.debug(‘**** Acc List–‘+ scope); delete scope; } global void finish(Database.BatchableContext BC) { system.debug(‘**** Finish’); } } global class ScheduleDelete implements Schedulable{ global void execute(SchedulableContext sc) { AccountDelete a = new AccountDelete(); database.executebatch(a); } } 2. Schedule the above class to run twice every day at 12:00 PM. Click here to learn more String CRON_EXP1 = ‘0 0 12,0 * * ?’ ; ScheduleDelete bt2 = new ScheduleDelete(); System.schedule(‘every 12 hour Batch Schedule’, CRON_EXP1, bt2);  3. Write a Script to delete the above Schedule Jobs. Click here to learn more String CRON_EXP1 = ‘0 0 12,0 * * ?’ ; ScheduleDelete bt2 = new ScheduleDelete(); ID jobId = System.schedule(‘every 12 hour Batch Schedule’, CRON_EXP1, bt2); system.debug(‘++++++++++’+jobId); system.abortJob(jobId); 4. Create Batch class to create 5 new Opportunities daily. Click here to learn more global class OpportunityBatch implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { String query = ‘SELECT Id,Name FROM Opportunity LIMIT 1’; return Database.getQueryLocator(query); }   global void execute(Database.BatchableContext BC, List<Opportunity> scope) { List <opportunity> oppnew = new List<opportunity>();  for(integer i=1;i<6;i++){ Opportunity opp = new Opportunity(); opp.name = ‘Test ‘ + i; opp.StageName = ‘Prospecting’; opp.CloseDate = Date.Today(); oppnew.add(opp); } system.debug(‘**** Opp List–‘+ oppnew); insert oppnew; }    global void finish(Database.BatchableContext BC) { system.debug(‘**** Finish’); } } global class OpportunityBatchScheduler implements Schedulable{ global void execute(SchedulableContext sc) { OpportunityBatch b = new OpportunityBatch();  database.executebatch(b); } } 5. Schedule the above class to run 4 times every day at after every 6 hours. Click here to learn more String CRON_EXP1 = ‘0 0 6,12,18,0 * * ?’ ; OpportunityBatchScheduler bt1 = new OpportunityBatchScheduler(); System.schedule(‘six hour Batch Schedule job1’, CRON_EXP1, bt1); 6. Write a Script to delete the above Schedule Jobs Click here to learn more String CRON_EXP1 = ‘0 0 6,12,18,0 * *...

Read More