You need to sign in to do that
Don't have an account?
Ganta Suresh
Can someone help me to convert this batch class into schedule flow -- if possible, with flow steps?
/*
Batch Class
Class Name :- NucleusTwocoveringMD
Functionality : - This Class is build for MDcomp record displaying it on MD Object.
*/
public class NucleusTwocoveringMD implements Database.Batchable<sObject>{
public map<string,Covering_MD_Responsibility__c> FTEMap = new map<string,Covering_MD_Responsibility__c>();
//public map<string,Medical_Director_Two__c> MDMap = new map<string,Medical_Director_Two__c>();
public list<Medical_Director_Two__c> MDList = new list<Medical_Director_Two__c>();
public list<Covering_MD_Responsibility__c> FCCList = new list<Covering_MD_Responsibility__c>();
public Set<String> MDCompId = new Set<String>();
public list<Medical_Director_Two__c> MDList2 = new list<Medical_Director_Two__c>();
public Database.QueryLocator start(Database.BatchableContext BC){
System.debug('in Start');
return Database.getQueryLocator([select id,Name,Covering_MD__c,Compensation_End__c,Compensation_Start__c from Hist_MD_Comp_Valuation_Support__c where Compensation_Start__c <=: date.today() AND Compensation_End__c >=: date.today()]);
}
public void execute(Database.BatchableContext BC, List<Hist_MD_Comp_Valuation_Support__c> scope){
System.debug('in execute');
MDList = [select id,Name,Physician_Name__c from Medical_Director_Two__c];
map<id,Medical_Director_Two__c> abc = new map<id,Medical_Director_Two__c>();
for(Hist_MD_Comp_Valuation_Support__c MDL : scope){
//MDMap.put(MDL.Physician_Name__c, MDL);
// Medical_Director_Two__c.add(MDL.Physician_Name__c);
MDCompId.add(MDL.Covering_MD__c);
}
System.debug('MDCompId = '+MDCompId);
List<Medical_Director_Two__c> NuMD = [select id,Name,Physician_Name__c from Medical_Director_Two__c where Physician_Name__c IN : MDCompId];
System.debug('NuMD = '+NuMD);
for(Medical_Director_Two__c NM : NuMD){
abc.put(NM.Physician_Name__c, NM);
}
System.debug('abc = '+abc);
for(Hist_MD_Comp_Valuation_Support__c MD : scope){
System.debug('abc.get(MD.Covering_MD__c) = '+abc.get(MD.Covering_MD__c));
if(abc.get(MD.Covering_MD__c) != null){
System.debug('IN check Map');
Covering_MD_Responsibility__c CMD = new Covering_MD_Responsibility__c();
System.debug('check Map');
CMD.Nucleus_MD__c = abc.get(MD.Covering_MD__c).id;
CMD.MD_Compensation__c = MD.id;
FCCList.add(CMD);
}
}
System.debug('FCCList = '+FCCList);
if(!FCCList.isEmpty()){
insert FCCList;
}
System.debug('FCCList = '+FCCList);
}
public void finish(Database.BatchableContext BC){
}
}
Batch Class
Class Name :- NucleusTwocoveringMD
Functionality : - This Class is build for MDcomp record displaying it on MD Object.
*/
public class NucleusTwocoveringMD implements Database.Batchable<sObject>{
public map<string,Covering_MD_Responsibility__c> FTEMap = new map<string,Covering_MD_Responsibility__c>();
//public map<string,Medical_Director_Two__c> MDMap = new map<string,Medical_Director_Two__c>();
public list<Medical_Director_Two__c> MDList = new list<Medical_Director_Two__c>();
public list<Covering_MD_Responsibility__c> FCCList = new list<Covering_MD_Responsibility__c>();
public Set<String> MDCompId = new Set<String>();
public list<Medical_Director_Two__c> MDList2 = new list<Medical_Director_Two__c>();
public Database.QueryLocator start(Database.BatchableContext BC){
System.debug('in Start');
return Database.getQueryLocator([select id,Name,Covering_MD__c,Compensation_End__c,Compensation_Start__c from Hist_MD_Comp_Valuation_Support__c where Compensation_Start__c <=: date.today() AND Compensation_End__c >=: date.today()]);
}
public void execute(Database.BatchableContext BC, List<Hist_MD_Comp_Valuation_Support__c> scope){
System.debug('in execute');
MDList = [select id,Name,Physician_Name__c from Medical_Director_Two__c];
map<id,Medical_Director_Two__c> abc = new map<id,Medical_Director_Two__c>();
for(Hist_MD_Comp_Valuation_Support__c MDL : scope){
//MDMap.put(MDL.Physician_Name__c, MDL);
// Medical_Director_Two__c.add(MDL.Physician_Name__c);
MDCompId.add(MDL.Covering_MD__c);
}
System.debug('MDCompId = '+MDCompId);
List<Medical_Director_Two__c> NuMD = [select id,Name,Physician_Name__c from Medical_Director_Two__c where Physician_Name__c IN : MDCompId];
System.debug('NuMD = '+NuMD);
for(Medical_Director_Two__c NM : NuMD){
abc.put(NM.Physician_Name__c, NM);
}
System.debug('abc = '+abc);
for(Hist_MD_Comp_Valuation_Support__c MD : scope){
System.debug('abc.get(MD.Covering_MD__c) = '+abc.get(MD.Covering_MD__c));
if(abc.get(MD.Covering_MD__c) != null){
System.debug('IN check Map');
Covering_MD_Responsibility__c CMD = new Covering_MD_Responsibility__c();
System.debug('check Map');
CMD.Nucleus_MD__c = abc.get(MD.Covering_MD__c).id;
CMD.MD_Compensation__c = MD.id;
FCCList.add(CMD);
}
}
System.debug('FCCList = '+FCCList);
if(!FCCList.isEmpty()){
insert FCCList;
}
System.debug('FCCList = '+FCCList);
}
public void finish(Database.BatchableContext BC){
}
}
You can reachout to accelerate team who can help your implementation request if you have premier support.
https://help.salesforce.com/s/articleView?id=000387492&type=1
Thanks,