Skip to content

Instantly share code, notes, and snippets.

@sachi-d
Last active October 31, 2020 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachi-d/df62baa33d0cf687a432590634c33767 to your computer and use it in GitHub Desktop.
Save sachi-d/df62baa33d0cf687a432590634c33767 to your computer and use it in GitHub Desktop.
Apex code stub for Enrolments class
public class Enrolments {
@InvocableMethod(label='Get Enrolments' description='Iterate over students, classes and payments and create junction records')
public static List<EnrolmentsResult> createEnrolments(List<EnrolmentsRequest> request){
//parse inputs and variables
List<Account> students = request.get(0).students;
List<Class__c> classes = request.get(0).classes;
List<Payment__c> payments = request.get(0).payments;
List<Enrolment__c> enrolments = new List<Enrolment__c>();
List<String> unenroledStudents = new List<String>();
//start of logic
//end of logic
//parse outputs
EnrolmentsResult result = new EnrolmentsResult();
result.enrolments = enrolments;
result.unenroledStudents = unenroledStudents;
List<EnrolmentsResult> resultList = new List<EnrolmentsResult>();
resultList.add(result);
return resultList;
}
public class EnrolmentsRequest{
@InvocableVariable
public List<Account> students;
@InvocableVariable
public List<Class__c> classes;
@InvocableVariable
public List<Payment__c> payments;
}
public class EnrolmentsResult{
@InvocableVariable
public List<Enrolment__c> enrolments;
@InvocableVariable
public List<String> unenroledStudents;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment