This document describes the steps to automate P2 Container Request via Flow.
Create an Invocable Apex Class
Create a Wrapper
Under the Invocable class, one need to create a wrapper by setting the following attributes as per requirement:-
public class P2ContainerRequestWrapper { public String sParentRecordId {get;set;} @AuraEnabled public String sTemplateName {get;set;} @AuraEnabled public String smsBody {get;set;} @AuraEnabled public String emailSubject {get;set;} @AuraEnabled public String emailBody {get;set;} @AuraEnabled public String defaultMessage {get;set;} @AuraEnabled public datetime lastOnline {get;set;} //Add another Object to Allow Multiple Recipient @AuraEnabled public List<Recipient> recipients {get;set;} public class Recipient{ @AuraEnabled public String firstName {get;set;} @AuraEnabled public String lastName {get;set;} @AuraEnabled public String email {get;set;} @AuraEnabled public String phone {get;set;} @AuraEnabled public List<RecipientItem> recipient_items {get; set;} @AuraEnabled public Boolean isTFAEnabled {get;set;} @AuraEnabled public String tfaMethod {get;set;} } @AuraEnabled public String firstName {get;set;} @AuraEnabled public String lastName {get;set;} @AuraEnabled public String email {get;set;} @AuraEnabled public String phone {get;set;} @AuraEnabled public String modeOfCommunication {get;set;} //Email, SMS or Both @AuraEnabled public DateTime expirationDate {get;set;} @AuraEnabled public Boolean tfaRequire {get;set;} @AuraEnabled public String tfaMethod {get;set;} @AuraEnabled public Boolean enableTeamFeature {get;set;} @AuraEnabled public Boolean bAutomation {get;set;} public String requesterFirstName {get;set;} Public String requesterLastName {get;set;} }
Set the values in the Wrapper
Create an object of Wrapper and set all the required values
P2ContainerRequestWrapper oWrapper = new P2ContainerRequestWrapper(); oWrapper.sParentRecordId = <Record Id of the record to which the P2 Request will be linked to>
Serialize the Wrapper
Serialize the wrapper using JSON.serialize method
String sWrapper = JSON.serialize(oWrapper);
Call the Global Method of Managed Package to initiate the process.
cm_datatransfer.GlobalServices.createP2Container(String sWrapper);