function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramkumar MurugesanRamkumar Murugesan 

Apex class with schedule job to collect data from user and store in custom object

I would like to collect the license informations from each market by salesforce and salesforce platform license from user object and store those informations based on the market value in a custom object called market info as mentioned in the below. There is no relation between two obejcts only the market picklist list is name in both the object

SELECT Id,IsActive,Market__c,Profile.UserLicense.Name, Name FROM User WHERE IsActive = true

SELECT Market__c,Number_of_Admin_Licences_NES__c,Number_of_platform_Licences_NES__c FROM Market_Info__c

For example: if the market is German , record is available in in the name of german. So  i will collect all the license information either it's admin or license.

can you please help me to write a schedule job and apex class for the same.
Gaurav NirwalGaurav Nirwal
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){
   }
}