Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This document describes the steps to automate P2 Container Request via Flow.

Table of Contents
exclude
maxLevel6
minLevel1maxLevel6
include
outlinefalse
indent
exclude
styledisc
typelist
classprintabletrue
class

Create an Invocable Apex Class

Create a Wrapper

  1. Under the Invocable class, one need to create a wrapper by setting the following attributes as per requirement:-

    Code Block
    public class P2ContainerRequestWrapper {
        public String sParentRecordId {get;set;}
     
      @AuraEnabled public String sTemplateName
    {get;set;}     @AuraEnabled public String smsBodyfirstName {get;set;} 
        @AuraEnabled public String emailSubjectlastName {get;set;}  
       @AuraEnabled public String emailBodyemail {get;set;}  
       @AuraEnabled public String defaultMessagephone {get;set;} 
       @AuraEnabled public datetimeString lastOnlinemodeOfCommunication {get;set;}
        //AddEmail, anotherSMS Object to Allow Multiple Recipientor Both
         @AuraEnabled public List<Recipient>DateTime recipientsexpirationDate {get;set;}
        public class Recipient{
      
         @AuraEnabled public StringBoolean firstNametfaRequire {get;set;} 
        
       @AuraEnabled public String lastNametfaMethod {get;set;} //If tfaRequire is set to True
       @AuraEnabled public String emailrequesterFirstName {get;set;} 
        
       @AuraEnabled public String phonerequesterLastName {get;set;} 
            
     @AuraEnabled   public List<RecipientItem>String recipient_itemssTemplateName {get; set;}
       
        @AuraEnabled public BooleanString isTFAEnabledsmsBody {get;set;}
     
          @AuraEnabled public String tfaMethodemailSubject {get;set;}
        }
      
         @AuraEnabled public String firstNameemailBody {get;set;}  
       @AuraEnabled public String lastNamedefaultMessage {get;set;}
        
    @AuraEnabled    public StringList<Recipient> emailrecipients {get;set;}
        public @AuraEnabled public String phone {get;set;}class Recipient{
           @AuraEnabled public String modeOfCommunicationfirstName {get;set;}  //Email,
    SMS or Both     @AuraEnabled public DateTimeString expirationDatelastName {get;set;} 
         @AuraEnabled   public BooleanList<RecipientItem> tfaRequirerecipient_items {get; set;}
        } @AuraEnabled
    public String tfaMethod {get;set;}  
       @AuraEnabled public Booleanclass enableTeamFeature {get;set;}RecipientItem{
        @AuraEnabled public Boolean bAutomation {get;set;}     public String requesterFirstNameinterface_class {get; set;}
            Publicpublic String requesterLastNamevalue {get; set;}
         }
    }

Set the values in the Wrapper

Create an object of Wrapper and set all the required values

Code Block
P2ContainerRequestWrapper oWrapper = new P2ContainerRequestWrapper();
oWrapper.sParentRecordId = <Record Id of the record to which the P2 Request will be linked to>

oWrapper.firstName <First Name of the End User to whom request needs to be sent>
oWrapper.lastName  <Last Name of the End User to whom request needs to be sent>
oWrapper.email     <Email of the End User to whom Request needs to be sent>
oWrapper.phone     <Phone of the End User to whom request needs to be sent>
oWrapper.modeOfCommunication  <Mode to send the P2 Request- email, sms or both>
oWrapper.expirationDate       <Expiration Date of the Container>
oWrapper.tfaRequire           <Set if TFA(2-Factor Authentication) is required on the Container>
oWrapper.tfaMethod            <Set the Method- Email or Phone if TFA is enabled>
oWrapper.requesterFirstName   <First Name of the User creating the Container>
oWrapper.requesterLastName   <Last Name of the User creating the container>

oWrapper.sTemplateName = <In case of using the Template no need to set SMS and Email Content>
OR
oWrapper.smsBody = <SMS Message to be sent for P2 Request>
oWrapper.emailSubject = <Email Subject for P2 Request>
oWrapper.emailBody = <Email Body for P2 Request>
oWrapper.defaultMessage = <Default Message if Any>

P2ContainerRequestWrapper.Recipient oRecipient = new P2ContainerRequestWrapper.Recipient();
oRecipient.FirstName = <First Name of the End User to whom request needs to be sent>
oRecipient.LastName = <Last Name of the End User to whom request needs to be sent>

P2ContainerRequestWrapper.RecipientItem oItem = new P2ContainerRequestWrapper.RecipientItem();
oItem.interface_class = <email or sms>
oItem.value = <emailaddress or phone number based on the interface class>
oRecipient.recipient_items = new List<P2ContainerRequestWrapper.RecipientItem>{oItem};    

oWrapper.recipients = new List<P2ContainerRequestWrapper.Recipient>{oRecipient}

Serialize the Wrapper

Serialize the wrapper using JSON.serialize method

Code Block
String sWrapper = JSON.serialize(oWrapper);

Invoke the P2 Container Service

Call the

...

global mathed of the managed packaged to initiate the creation of P2 Request. The method will return a map holding the record Id of the P2 Request in case of success and error message in case of any failure.

Code Block
Map<String, Object> mapResponse = cm_datatransfer.GlobalServices.createP2Container(String sWrapper);