top of page

Save 43 manual steps PER INVOICE -Automated landed cost freight invoice processing via attended RPA


1. Overview

2. Configure AI model for form processing and create PowerAutomate flow with AI model

3. Landed cost configuration for auto costing

4. Custom Development in D365F0

5. Set up and configure PowerAutomate desktop for attended RPA

6. Configure PowerAutomate instant flow for RPA processing

7. Configure PowerApp for freight invoice processing

8. End to end process - Demonstration

1. Overview

The new Landed Cost module for Dynamics 365 Supply Chain Management helps businesses streamline inbound shipping operations by giving users complete financial and logistical control over imported freight, from the manufacturer to the warehouse. Auto costing is used to estimate freight, duty, local transportation and other charges for inbound transportation which is trued up later when the actual freight vendor invoice is recorded. In that context, I bridge the gap with a solution that leverages RPA and AI Builder to process via email received freight invoices in a streamlined and automated fashion. Processed information are stored in Dataverse. Via PowerApps and with use of PowerAutomate and PowerAutomate desktop, actual invoice information are lastly processed by a RPA bot and recorded in D365FO. This solution can save 43+ manual steps to be executed by an end user per invoice.

Environment/Infrastructure requirements:

- Dynamics 365 for Supply Chain Management Environment (I used my Tier 1 dev box)

- Powerplatform environment (I used a trial instance - Find details under

License requirements:

- Microsoft PowerAutomate Free

- PowerApps per app

- PowerAutomate per user with attended RPA plan

- Microsoft 365 E3

- AI Builder trial

- Dynamics 365 for Supply Chain Management

Components used:

- AI Builder (Form processing)

- PowerApps (with premium connectors)

- PowerAutomate (with premium connector)

- PowerAutomate Desktop (with onprem gateway)

- Dynamics 365 for Supply Chain Management (Landed cost module and custom entity development required)

2. Configure AI model for form processing and create PowerAutomate flow with AI model

I configure an AI form processing model that processes invoice information from an pdf document received via email. It sends out an confirmation email to the person in charge of invoices within your organization and it saves the processed data in a custom Dataverse table.

I navigate to and create an AI Model for form processing.

After selecting form processing, I am prompted to specify a name for my AI model.

After creation, I added tags for all information on the invoice that I want to extract. Here, I make sure that I extract all information that I later need/want to process in Dynamics 365 for Supply Chain Management. (e.g. Invoice number, Duty Charges, Vendor name, Fuel Charges, etc.)

I manually created 5 invoice documents and saved them locally as pdf documents. AI models require at least 5 source documents to train the model. See below my example documents:

Freight Invoice Samples
Download ZIP • 296KB

After confirming the tags, I added a new collection and uploaded the 5 documents mentioned above.

As stored locally, I select "upload from local storage".

You can see the upload is processing.

After the upload is completed, I select the "Analyze" button. This takes a view minutes. After that's done, I am able to map fields on the right side to information on the invoice pdf document - See below.

E.g. for invoice number field/tag:

After all tags/fields are mapped for all 5 uploaded documents (documents need to have the same layout), the model can be trained - Press Next.

In the next screen, I can see and review the model summary and if all looks fine I can progress with training the model. This take also a few minutes.

After the model is trained, I can review the model's performance and publish the model.

For validation purposes, I go to quick test under Models and upload a sample invoice to test the model for accuracy.

See the results are on point and in alignment with my mappings set up prior.

As I successfully tested the model, I am ready to publish the AI model under Models now.

After the model is published, I can use the model for my PowerAutomate flow.

I click "Use model "and "+ New flow in Power Automate".

I allow/grant access to Dataverse, Office 365 Users and Office 365 Outlook.

After doing so, a standard flow is automatically created so I do not need to start from scratch. I do not adjust the "Process and save information from forms" as well as the "Get my profile" actions. However, there are a few adjustments on other actions that I have to do. First, save and rename the flow - Here, I chose "LandedCostInvoice_FormProcessing".

The following adjustments were made to the standard flow automatically created:

- I deleted the welcome action.

- In the "When a new email arrives (V3)" action, I could potentially adjust the subject filter to "Invoice" instead of "AI Model" so all emails with subject "Invoice" would be processed by my automated flow. For now, I left "AI Builder" for simplicity.

- I adjust the condition in the "Apply to each" action to "Has attachment" equals "True".

Before continuing with what needs to be adjusted in the PowerAutomate flow now, I require a custom table in Dataverse as I reference fields of that custom table within the flow.

That said, I navigate to and under Data/Tables, I create a new custom Dataverse Table. I create this new custom Dataverse Table so I can save the information processed in table tailored for our needs.

See below the Dataverse/Tables form:

I create a new table by clicking "+ New table" and add information required.

After confirming, the columns form appears. Some standard fields have already been created at time of table creation by default. However, I still require our custom fields to be created. To do so, we leverage the "+ add columns" option.

I added the following fields/columns:

- Invoice number - Data type: Whole number

- Transportation charges - Data type: Decimal number

- Duty charges - Data type: Decimal number

- Fuel charges - Data type: Decimal number

- Insurance charges - Data type: Decimal number

- Freight vendor - Data type: Text

- Invoice date - Data type: Date only

- VoyageID - Data type: Text (This field does not come from the processed invoice as the freight vendor does not know the D365FO specific voyage number sequence. We later use a PowerApp to patch the correct D365FO voyage ID from D365FO to the processed invoice in Dataverse)

- Total - Data type: Decimal number

- Weight - Data type: Decimal number

- Dimensions - Data type: Text

See an example for Invoice number below:

Lastly, save the table and see the final result:

After doing so, I continue editing my PowerAutomate flow. I edited the "send an email (V2)" action and its subject and body. This email will be sent to the employee in charge of invoices.


"Document processed"


"Hello <get my profile - given name variable>,

I hope you and your family are doing well.

A freight invoice has been processed and information have been extracted to Dataverse. Please match external freight invoice number to voyage ID from Microsoft Dynamics 365 for Supply Chain Management's Landed cost module and kick off the automated freight invoice recording process via PowerApp.

Link to the PowerApp: <we later paste the PowerApps URL here for the PowerApp that we are creating>

Key invoice information extracted:

Total: <Output - Total value > (Confidence score: <Output - Total confidence score>)

Invoice number: <Output - Invoice number value > (Confidence score: <Output - Invoice number confidence score>)

Vendor name: <Output - Vendor name value > (Confidence score: <Output - Vendor name confidence score>)

Thank you so much!

Best Wishes,

Chris Segurado"

After doing so, I added a "new row 2" action. Here, I can now reference the created Dataverse table called "LandedCostInvoices" and its columns/fields - short I can now specify columns/fields where we want to save/store the processed data,.

The unique LandedCostInvoice identifier/primary key (should not be invoice number as there is a chance that different freight vendors may send you an invoice with the same invoice number) is specified with UtcNow what saves the timestamp. I chose this design as let's say you have 2 different freight vendors, there is a chance that invoice numbers may fall on the same number. As we require a unique identifier the timestamp should do. For Invoice number, Fuel charges, Duty charges, Insurance charges, Invoice number, Total, Transportation charges and Weight outputs, I added a function that transforms outputs to string values to be passed on to the custom Dataverse table. (In my scenario, this is required as it otherwise errors when trying to create a record in Dataverse)

After doing the adjustments, I save and close.

To sum it up and as a quick recap on what we are trying to accomplish here: I trained an AI model that will process an via email incoming invoice pdf document. The PowerAutomate flow will be triggered for all incoming emails to the specified mailbox with subject "AI builder" as well as where the attachments equals true action is true. An confirmation email with invoice key information such as vendor name, total and invoice number is sent to the employee that is responsible for invoice posting/review. This confirmation email also contains a link to the PowerApp where the employee continues invoice processing later by kicking off the RPA bot. The processed information are stored in a custom Dataverse table. So far, so good.

As a next step, I am setting up Dynamics 365 for Supply Chain Management - Landed Cost Module.

3. Landed cost configuration for auto costing

Please follow my prior posted blog for details on how to set up auto costing and the landed cost module:

4. Custom Development in D365F0</