...
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;} public String sTemplateNamefirstName {get;set;} public String smsBodylastName {get;set;} public String emailSubjectemail {get;set;} public String emailBodyphone {get;set;} public String defaultMessagemodeOfCommunication {get;set;} //AddEmail, anotherSMS Object to Allow Multiple Recipientor Both public List<Recipient>DateTime recipientsexpirationDate {get;set;} public class Recipient{ public StringBoolean firstNametfaRequire {get;set;} public String lastNametfaMethod {get;set;} //If tfaRequire is set to True public String emailrequesterFirstName {get;set;} public String phonerequesterLastName {get;set;} public List<RecipientItem>String recipient_itemssTemplateName {get; set;} } public String firstNamesmsBody {get;set;} public String lastNameemailSubject {get;set;} public String emailemailBody {get;set;} public String phonedefaultMessage {get;set;} public StringList<Recipient> modeOfCommunicationrecipients {get;set;} //Email, SMS or Both public class Recipient{ public DateTimeString expirationDatefirstName {get;set;} public BooleanString tfaRequirelastName {get;set;} public String tfaMethodemail {get;set;} //If tfaRequire is set to True public String requesterFirstNamephone {get;set;} public StringList<RecipientItem> requesterLastNamerecipient_items {get; set;} } }
Set the values in the Wrapper
...
Code Block |
---|
P2ContainerRequestWrapper oWrapper = new P2ContainerRequestWrapper(); oWrapper.sParentRecordId = <Record Id of the record to which the P2 Request will be linked to> oWrapper.sTemplateNamefirstName =<First <In caseName of usingthe theEnd TemplateUser to setwhom Email Body and SMS Message from the Template> oWrapper.smsBody = <SMS Messagerequest needs to be sent for P2 Request>sent> oWrapper.emailSubjectlastName =<Last <EmailName Subjectof forthe P2End Request>User oWrapper.emailBodyto =whom <Emailrequest Bodyneeds forto P2be Request>sent> oWrapper.defaultMessageemail = <Default Message if Any><Email insertof oWrapper;the End RecipientUser orecipient = new Recipient(); recipient.cm_datatransfer__P2_Request__c = <Id of the P2Container RequestWrapper> recipient.FirstName = <First Nameto whom Request needs to be sent> oWrapper.phone <Phone of the End User to whom request needs to be sent> recipientoWrapper.LastNamemodeOfCommunication = <Last<Mode Nameto ofsend the End User to whom request needs to be sent> recipient.Email = <EmailP2 Request- email, sms or both> oWrapper.expirationDate <Expiration Date of the EndContainer> UseroWrapper.tfaRequire to whom Request needs to be sent> recipient.Phone = <Phone of<Set the End User to whom request needs to be sent>if TFA(2-Factor Authentication) is required on the Container> oWrapper.tfaMethod insert recipient; oWrapper.firstName <First Name of<Set the EndMethod- UserEmail toor whomPhone requestif needsTFA tois beenabled> sent> oWrapper.lastNamerequesterFirstName <Last<First Name of the End User tocreating whomthe request needs to be sent> Container> oWrapper.emailrequesterLastName <Last <EmailName of the End User tocreating whomthe Request needscontainer> to be sent> oWrapper.phonesTemplateName = <In case of <Phoneusing ofthe theTemplate Endno Userneed to whomset requestSMS needsand toEmail beContent> sent>OR oWrapper.modeOfCommunicationsmsBody = <SMS <ModeMessage to sendbe sent thefor P2 Request- Email, SMS or Both>Request> oWrapper.emailSubject = <Email Subject for P2 Request> oWrapper.expirationDateemailBody = <Email Body for P2 Request> <ExpirationoWrapper.defaultMessage Date= of<Default theMessage Container>if oWrapper.tfaRequireAny> List<Recipient> listRecipient = new List<Recipient>(); P2ContainerRequestWrapper.Recipient oRecipient = <Set if TFA is required onnew P2ContainerRequestWrapper.Recipient(); oRecipient.FirstName = <First Name of the Container>End oWrapper.tfaMethodUser to whom request needs to be sent> oRecipient.LastName = <Last Name <Setof the Method-EmailEnd orUser Phoneto ifwhom TFArequest isneeds enabled>to oWrapper.requesterFirstNamebe sent> oRecipient.Email <First= Name<Email of the End User creating the Container> oWrapper.requesterLastName <Last Nameto whom Request needs to be sent> oRecipient.Phone = <Phone of the End User creating the container> to whom request needs to be sent> listRecipient.add(oRecipient); oWrapper.recipients = listRecipient; |
Serialize the Wrapper
Serialize the wrapper using JSON.serialize method
...