I want to know if there is a way to relate records when the information is coming from Schedulable callouts, I created other classes to create the first and the second list of records but now I need to relate them, for what I thought it was a good idea it was to get the record ID's from the first and second list of records
First List of Records:
Second List of Records:
What have tried is to get a list of those board's id's from the first object:
List<String>Boardids = new List<String>();
for(Educational_Program__c EP :[Select Boards_IDs__c from Educational_Program__c where Boards_IDs__c != null] )
{
Boardids.add(EP.Boards_IDs__c);
}
String commaBoardsid = String.join(Boardids, ', ');
String Boardsidcomma = commaBoardsid.replaceAll('\\n', ', ');
List<String>lsdt = Boardsidcomma.split(',');
Then with the list, I was trying to loop and perform SOQL to get the ids from the records from the first and second object to get the object and finally create the related record:
List<Educational_Program_Claned_Board__c> relatedEDP = new List<Educational_Program_Claned_Board__c>();
List<id> CBid = new List<id>();
List<id> EPids = new List<id>();
for(Integer i=0; i<lsdt.size(); i++)
{
List<Educational_Program__c>AEP = [Select id from Educational_Program__c where Boards_IDs__c = :lsdt[i]];
EPids.add(AEP.id);
List<Claned_Board__c>ACB = [Select id from Claned_Board__c where Claned_Board_Id__c =: lsdt[i] ];
CBid.add(ACB.id);
Educational_Program_Claned_Board__c wrkrelatedEDP = new Educational_Program_Claned_Board__c();
wrkrelatedEDP.Board__c = CBid ;
wrkrelatedEDP.Educational_Program__c = EPids;
relatedEDP.add(wrkrelatedEDP);
}
insert relatedEDP;
But when I Executed this in Anonymous I got the Error: Variable does not exist: id I tried to identify the reason of the error but I was unable to identify it.
So, I created a flow to relate the records when the second list of records is created, but the flow only related those that are not in a group, is there a way to separate those values using a formula inside the flow or is going to be needed to use Apex to related all of them?