This document describes the steps to automate P2 Container Request via Flow.
Table of Contents | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Create an Invocable Apex Class
...
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 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;} //If @AuraEnabled public Boolean enableTeamFeature {get;set;} @AuraEnabled public Boolean bAutomation {get;set;}tfaRequire is set to True public String requesterFirstName {get;set;} Publicpublic String requesterLastName {get;set;} }
...
Code Block |
---|
P2ContainerRequestWrapper oWrapper = new P2ContainerRequestWrapper();
oWrapper.sParentRecordId = <Record Id of the record to which the P2 Request will be linked to>
oWrapper.sTemplateName = <In case of using the Template to set Email Body and SMS Message from the Template>
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>
insert oWrapper;
cm_datatransfer__Recipient__c recipient = new cm_datatransfer__Recipient__c();
recipient.cm_datatransfer__P2_Request__c = <Id of the P2Container RequestWrapper>
recipient.cm_datatransfer__First_Name__c = <First Name of the End User to whom request needs to be sent>
recipient.cm_datatransfer__Last_Name__c = <Last Name of the End User to whom request needs to be sent>
recipient.cm_datatransfer__Email__c = <Email of the End User to whom Request needs to be sent>
recipient.cm_datatransfer__Phone__c = <Phone of the End User to whom request needs to be sent>
insert recipient;
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 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>
|
Serialize the Wrapper
Serialize the wrapper using JSON.serialize method
...