The address book is used as a way to pre-fill an address form from an existing address, without the user having to type it from scratch. Because Limio for Salesforce is only aware of addresses stored in Limio, this is the list that by default the flow retrieves.
The apex action Get Customer Addresses returns a list of addresses from the customer record in Limio, and stores the output in the flow variable CustomerAddresses.
This step can be customised by passing additional addresses from other records in the org, for a more tailored experience based on the org setup. The output generated must be a
List<i42as.CustomerAddress>
where i42as is the namespace for Limio for Salesforce. The CustomerAddress apex class is a global class with the following properties
Learn more about the class here: Global Apex class: CustomerAddress
Below is an example that returns an address book entry from the billing address fields on the account
List<i42as.CustomerAddress> addressToReturn = new List<i42as.CustomerAddress>();
List<Account> accounts = [SELECT FirstName, LastName, BillingCity, BillingCountry, BillingPostalCode, BillingState, BillingStreet, BillingBuildingNumber, BillingStreetName FROM Account WHERE Id=: caseRecord.AccountId LIMIT 1];
if (accounts.size() > 0) {
i42as.CustomerAddress address = new i42as.CustomerAddress();
address.FirstName = accounts[0].FirstName;
address.LastName = accounts[0].FirstName;
address.MailingStreet = accounts[0].BillingStreet;
address.MailingCity = accounts[0].BillingCity;
address.MailingPostalCode = accounts[0].BillingPostalCode;
address.MailingState = accounts[0].BillingState;
address.MailingCountry = accounts[0].BillingCountry;
address.id = 'billingaddressid';
address.label = accounts[0].BillingStreet + ' ' + accounts[0].BillingCity + ' ' +accounts[0].BillingPostalCode;
addressToReturn.add(address);
// building number and street name can be mapped from your custom field:
address.MailingBuildingNumber = accounts[0].customBillingBuildingNumber;
address.MailingStreetName = account[0].customBillingStreetName;
}
The generated output can be stored on the CustomerAddresses variable of the flow, that is of the same type.
This variable can then be passed to components that use an address book, like the delivery address book or the payment method iframe.
Comments
0 comments
Please sign in to leave a comment.