Overview
The Email to Payable feature creates a Payable once it is emailed to a configured email address. For customers using Multi-company (Ledger), a flow can be set up to populate the Ledger, Owner, and other fields on the Payable that are created based upon the email address where the invoice was emailed. For example, if the Vendor emailed an invoice to accountspayable@company1.com, the Ledger on the Payable would be updated to “Company 1.” If it was emailed to the email address for Company 2, then the flow would be set this value on the Ledger.
Before creating the flow, you will need to create a Custom Metadata Type to configure the Email ID to the Ledger mapping. This will ensure that you have a unique email address for each Ledger as in the example above. Complete the following:
Create a Custom Metadata Type
- Click the Gear icon and select Setup.
- Enter Custom Metadata in the Quick Find textbox. Then, select Custom Metadata Types.
- Click New Custom Metadata Type.
- Enter Email to Ledger Mapping in the Label field.
- Enter Email to Ledger Mappings in the Plural Label field.
Note: Click here to view the above image in full screen.
- Click Save.
- From the Custom Fields section, click New.
- Create the following two new Custom Fields.
- Email (under Data Type, select the Email radio button and enter Email in the Field Label.)
- Ledger (Under Data Type, select the Text radio button and enter Ledger in the Field Label. Enter 255 as the Length.)
- (Optional) Create additional Custom Fields, as necessary if you would like to update any other fields on Payables automatically. For example, a customer might want to update the Owner on a Payable.
Note: Click here to view the above image in full screen.
Important: If you want to update other fields, such as Owner, etc., you will need to create the additional custom fields in the same Custom Metadata Type before including them in the flow.
Configure the Flow
- To create a new Flow, click the Gear icon and select Setup.
- Enter Flow in the Quick Find textbox, and click Flows.
- Click New Flow.
- Select Start From Scratch.
- Click Next.
- Select Record-Triggered Flow, and click Create.
- Select Email Message from the Object drop-down list.
- Select the A Record is Created radio button.
- At the bottom of the screen, select the Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed checkbox.
Best Practice: We recommend using the asynchronous path so that any error messages from the flow will not fail the actual transaction.
Note: Click here to view the above image in full screen.
-
In the left panel, click the plus sign (+) under Run Asynchronously, and select the Get Records element. Then, complete the fields below.
Note: Keep in mind that this flow will run after a Payable has automatically be created.
- Enter Get AP Record in the Label field. The API Name will automatically update.
- Select Payable from the Object drop-down list.
- From Field, select Id for the Record ID.
- Equals should be selected as the Operator.
- Select $Record > RelatedToId as the Value (select the first value, then select the second value, and press Enter to display both values as in the screen capture below).
Note: Click here to view the above image in full screen.
- Scroll down, and click the Choose fields and assign variables (advanced) radio button. Then, do the following:
- Select the Together in a record variable radio button.
- In the Record field, select New Resource.
- Select Variable from the Resource Type drop-down list.
- Enter RelatedAP as the API Name.
- Select Record as the Data Type.
- Select Payable as the Object.
- Click Done.
- In the Select Payable Fields to Store in Variable Field, ID should be the field that is selected.
- Click Add Field. Then, add AcctSeed__Ledger__c in the new field textbox.
- Select the When no records are returned set specified variables to null checkbox.
Note: Click here to view the above image in full screen.
- Click the plus sign (+) under Run Asynchronously, and select the Decision element to determine if a Payable record was successfully retrieved. Then, complete the below.
Note: If a Payable record does not exist, the flow can be set to end since the email did not create a Payable.
- Enter Check if AP Exists? in the Label field. The API Name will automatically update.
- Enter Exists in the Label field. The Outcome API Name will automatically update.
- Select RelatedAP in the Resource field.
- Select Is Null as the Operator.
- Select False as the Value.
- Click OK.
Note: Click here to view the above image in full screen.
- Click the Get AP Record element. Then, select Edit Element.
- Under Exists, click the plus sign (+) to select the Get Records element to get the Email to Ledger mapping Custom Metadata configuration. This will retrieve the values from all Custom fields in the Metadata configuration for the given email address.
Note: Click here to view the above image in full screen.
- Add a Get Records element to retrieve the Record Id on the Ledger, as well as any other Custom fields that were added to the Custom Metadata to update on Payables, such Owner, etc.
- Scroll down, and click the Choose fields and assign variables (advanced) radio button. Then, do the following:
- Select the Together in a record variable radio button.
- In the Record field, select New Resource.
- Select Variable from the Resource Type drop-down list.
- Enter Ledger as the API Name.
- Select Record as the Data Type.
- Select Ledger as the Object.
- Click Done.
- In the Select Ledger Fields to Store in Variable Field, ID should be the field that is selected.
- Select the When no records are returned set specified variables to null checkbox.
Note: Click here to view the above image in full screen.
- Create a Decision element to verify that the Ledger exists.
Note: Click here to view the above image in full screen.
- Click the plus sign (+) under the Exists path to add the Update Records element to update the Payable.
Note: Click here to view the above image in full screen.
- Click Save to save the flow.
Note: If you included additional fields (such as Owner, etc.) from the Payable record, the flow would display with the additional elements (different from the example above).
Comments
0 comments
Please sign in to leave a comment.