Created
October 23, 2017 12:50
-
-
Save manzanit0/ff1fa64f8c8f696d3e3e132fa8864c17 to your computer and use it in GitHub Desktop.
Quick implementation of an Apex Batch, from the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global class SearchAndReplace implements Database.Batchable<sObject>{ | |
| global final String Query; | |
| global final String Entity; | |
| global final String Field; | |
| global final String Value; | |
| global SearchAndReplace(String q, String e, String f, String v){ | |
| Query=q; Entity=e; Field=f;Value=v; | |
| } | |
| global Database.QueryLocator start(Database.BatchableContext BC){ | |
| return Database.getQueryLocator(query); | |
| } | |
| global void execute(Database.BatchableContext BC, List<sObject> scope){ | |
| for(sobject s : scope){ | |
| s.put(Field,Value); | |
| } | |
| update scope; | |
| } | |
| global void finish(Database.BatchableContext BC){ | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment