A practitioner’s views on…

  • Call Data Management in Dynamics 365 Finance and Operations using OData Actions

    Call Data Management in Dynamics 365 Finance and Operations using OData Actions

    With OData actions we are able to invoke operations in Data Management. This way we can start import and export jobs or query various data elements.

    This is useful when we want an external application or user to create files on demand.

    In this example I am using the OData actions to export data to a spreadsheet and subsequently open the spreadsheet from a Power Apps app.

    In Data Management, we do not need to anything special to make this work. In principle, any data project can be called using an OData action.

    The below screenshot shows the definition of the “Customer FTI” data job I will be using in this example.

    The Power Apps App

    To make this example meaningful, I have created a simple Power Apps app that displays the Data Management data projects in a gallery as shown below.

    Not pretty but it does the job…

    In the OnSelect action on the arrow in the gallery, I have added a single line of code:

    Launch(ExportDataPackage.Run(Gallery1.Selected.Description).filepath)

    The code calls a Power Automate flow called “ExportDataPackage”. This flow returns the full path to the file generated by the selected data job.

    The selected data job ID (Description field) is passed to the flow as a variable.

    The Power Automate Flow

    Obviously, the interesting part of this example is the Power Automate flow so let us have a look at it.

    The flow is an instant type of flow, and we start by capturing the data job ID passed from the app and put it into a variable name DefinitionGroupId.

    Next, we generate a fresh GUID value. This value is used later on to give our job execution an identification and store the data package.

    In the above action, we call the OData action to export a data package from Data Management. The data project ID we received from the app is used to identify the data job to call and the ExecutionID GUID we generated earlier identifies the actual job we are executing.

    This step, assuming it is successful, generates a data package (ZIP archive) in the dedicated Dynamics 365 Finance and Operations (D365F&O) storage area.

    To retrieve the data package, we need to get the URL that points to where it is placed. We can use the GetExportedPackageUrl OData action to get the URL. In this example, I have placed the action inside a Do-until condition since there may be a slight delay when generating the package.

    Subsequently, we can use an HTTP action to retrieve the actual data content using the URL we got in the previous step.

    Now that we have the package content, we need to retrieve the files from the archive and place them in a usable folder. In this case we are using the OneDrive connector to perform the necessary file manipulation.

    First, we use the body content from the HTTP call to generate the archive on OneDrive.

    Then, we extract the files in the archive into a new folder named with the ExecutionID.

    Lastly, since we do not always know the name on the spreadsheet file generated by the data job, we find the first file in the folder with the “.XLSX” extension.

    When the file has been found, we continue to use the OneDrive connector to generate a link to the file.

    As you may remember from the app section above, we used the Launch command to open the file we have generated. This command takes a URL as a parameter so we can pass the link we generated in the above step to the command, and it will open the spreadsheet in a browser tab.

    In the final step, we pass the link to the spreadsheet file back to the app.

    Testing

    Now everything has been configured, it is time to test it.

    When I click on the arrow on the row containing the “Customer FTI” data job, the flow is invoked and generates the data package on OneDrive as shown below.

    The flow has also extracted the files from the archive into a folder with same name.

    In this case, the data package contains a spreadsheet file named “Customer free text invoice.xlsx”.

    The above screenshot shows how the Launch command has opened the spreadsheet in a tab in the browser.

  • Dynamics 365 for Finance and Operations Inventory Cost Model, Part 4: Landed Cost

    Dynamics 365 for Finance and Operations Inventory Cost Model,  Part 4: Landed Cost

    This is the fourth instalment in my series of articles explaining the inventory cost model in Dynamics 365 for Finance and Operations (D365FO). The series is expected to include the following parts:

    In the previous posts, we looked at the core concepts underpinning the inventory cost model in D365FO and how some of the key areas should be configured. In this post we will look more into how you work with landed cost.

     

    I am not sure if there is a formal definition of what landed cost is, but for the purpose of this article landed cost is defined as:

    Total cost of an inbound shipment of goods including product cost, freight, insurance and duties.

    The concept of charges

    In D365FO, landed costs are recorded and managed through so-called Charges. A charge can be any type of landed cost and can be set up for products and suppliers. A charge is a relatively simple concept based on the following business logic:

    • A Charge can be applied to a purchase order header or lines manually or automatically.
    • A charge cannot be split across multiple purchase orders.
    • A purchase order header charge can be allocated across the purchase order lines (manually).
    • Purchase order line charges can be included in the product cost and taken into the inventory.
    • A charge can only be applied to the supplier on the purchase order – not a 3PL supplier.
    • Charges on a purchase order are perceived to be estimated – realised charges are connected to the invoice.

    Configuring charges

    Before we can use Charges in D365FO, they need to be configured. Since we are dealing with inbound charges, the configuration takes place in the Procurement and sourcing module under Setup / Charges.

    Firstly, we must configure the necessary charge codes as shown in the following example.

    Inventory 1.PNG

    The key decision to make here is how to post the charge to the general ledger. In this case, FREIGHT, the cost (debit) is posted to a nominal ledger account (600120) and the debt (credit) is included is the amount owed to the supplier and therefore the accounts payable account set up for the supplier.

    In the next example, FEE, the debit configuration is pointing to Item. This means that the charge will go to the inventory account for the item on the purchase order line and be included in the inventory value.

    Inventory 2.PNG

    Obviously, charge codes with debit posting set to Item are only relevant for purchase order line charges.

    Once the charge codes have been defined, they can be used manually on a purchase order. However, most companies would like to have default charges applied automatically. This is set up as Automatic charges.

    Firstly, I have set up a handling fee of $5.00 for vendor 1001 as shown in the following example. This is set up as a Header charge.

    Inventory 3.PNG

    This means. that all purchase orders for vendor 1001 will have a handling charge applied to the purchase order header automatically.

    Next, I have set up two line item charges for freight and fee respectively. The freight charge is multiplied by the quantity on the purchase order line. The fee charge is a fixed amount for each purchase order line.

    Inventory 4.PNG

    The charges are automatically applied to all purchase order lines for vendor 1001, item 1000.

    I could also have set up automatic charges for a group of vendors or a group of items. These groups are maintained in special charges groups.

    Use of charges in the purchasing process

    When I create a new purchase order for vendor 1001, the handling charge is automatically applied as shown in the following screenshot.

    Inventory 5.PNG

    If required, I can add, change or delete charges in the purchase order header. Charges in the purchase order header are maintained under Maintain charges.

    The purchase order header charge is a general charge that will not be included in the inventory value. The charge can be allocated to the purchase order lines instead by using the Allocate charges menu point as shown below.

    Inventory 6.PNG

    Now, when I create a purchase order line for item 1000, the freight and fee charges are automatically applied as shown here.

    Inventory 7.PNG

    Since the fee charge is fixed, it does not change with the order quantity whereas the freight charge does.

    Once the purchase order has been confirmed to the supplier, changes to charges cannot be applied until the invoicing stage.

    Invoicing matching

    At the invoicing stage, the user cannot remove the estimated charges on the purchase order. The purchase order charges are automatically connected to the invoice charges, but the user can remove the connection and apply new corrected charges. This way, the user can match the invoicing but at the same allow comparison between estimated charges and actual charges for that purchase order.

    Charges postings

    The following screenshot shows the inventory transaction details for the purchase order line after the supplier invoice has been applied.

    Inventory 8.PNG

    As you can see, the purchase order line amount of $1,798.00 has been increased to $1,798.50 because of the $0.50 fixed fee charge. This charge has been included in the inventory value because the charge code was set up to post the debit side to the item.

    If we look at the financial voucher for the purchase order as a whole, we can see that the $2.00 freight charge has been taken to the “Freight/transportation in” account and the $5.00 handling charge has gone to “Other miscellaneous expenses” account. Lastly, it is worth noting that the accumulated charges have been added to the accounts payable account as well.

    Summary

    The above example pretty much sums up what can be achieved with charges in D365FO. If your requirements involve distributing freight charges across multiple purchase orders, the Transportation management module may be applicable, but it is beyond the scope of this article.

    As mentioned, the system keeps both the estimated and the realised charges, but I have yet to find a report that shows a comparison or any statistics.

     

     

  • Hasta La Vista, baby

    Hasta La Vista, baby

    Dear Readers,

    After 10 years, this blog has finally reached the end of the line.

    It has been great for me to share what I know about Dynamics 365 Finance and Operations and see how the audience and community around the product has grown.

    I would like to send a BIG thank you to you, dear reader, for reading my blog and giving great feedback.

    This does not mean, that I will stop sharing with the community.

    However, my future platform is LinkedIn where I will share articles and videos.

    On LinkedIn I have created a monthly newsletter. You can subscribe to the newsletter by using the below link…

    Subscribe on LinkedIn

    Again, thank you for reading – hope to see you again on LinkedIn.

    /Henrik

  • Purchase Order Holds in Dynamics 365 Finance and Operations

    Purchase Order Holds in Dynamics 365 Finance and Operations

    Until recently it was not possible to put a vendor on hold for purchase orders only. Instead, the vendor had to be put on hold for all transaction types, which meant that you were unable to process outstanding invoices and payments, which was not ideal in some cases.

    Now, with this new feature, you can put vendors on hold for purchase orders and continue to process invoices and payments.

    How Does It Work?

    From the Vendor form select On hold from the ribbon. This drops down a sub menu where you select the vendor hold type first. In this case, we select “Purchase order” from the drop-down.

    Next, we can enter a date for when the hold is automatically released and a hold reason code.

    Lastly, if the vendor is used in multiple legal entities, we need to determine if the vendor is blocked across all legal entities.

    Purchase Order Entry

    When I try to use the vendor (1001 Acme Office Supplies) on a purchase, I get an error saying that the vendor is stopped for purchase orders.

    Please note, although the vendor is on purchase order hold, a purchase order can still be confirmed and received.

    Process Pending Invoice

    As you can see from the above, when I generate a pending invoice from a purchase order that was created before the vendor was put on hold, the invoice is generated without error and the invoice can be posted.

  • Tax Calculation Service in Dynamics 365 Finance and Operations

    Tax Calculation Service in Dynamics 365 Finance and Operations

    The new tax calculation service for Dynamics 365 Finance and Operations (D365F&O) is slowly maturing, so it is time to take a look at how it works.

    Before you can start using the tax calculation service there is quite a lot of technical configurations to be done in this iteration of the solution. This article describes in detail what must be done, and it is important to follow all steps to the letter – otherwise you will have issues down the line.

    Detailed information on how to set up and use the tax calculation service can be found here.

    Creating a New Tax Feature

    As you will have noticed when going through the above configuration, the service is managed in the Regulatory Configuration Service (RCS). If everything has gone according to plan, there should now be a tile named Globalization features in the RCS dashboard. If not, something has gone wrong…

    To set up tax configuration, you must click on this tile and then on the Tax calculation tile in the next screen as shown below.

    Tax calculation tile

    This opens up the landing page for tax calculation feature configuration.

    Tax features landing page

    In our example, we would like to create a new tax feature that holds tax configuration for the “DEMF” legal entity. A new tax feature is created by clicking on the Add button and you can either create a feature from scratch or base it on an existing feature.

    Create new tax feature from scratch

    When I click on Create feature the system creates a new draft version on the right-hand side. All the changes I make are in draft until I decide to publish the model.

    After I click on the Edit button in the version view, I need to select the configuration version I base my feature on. The configuration version is the electronic reporting model you imported during basic configuration.

    If the drop-down is empty you need to go back to basic configuration.

    Configuration version selected

    Next, you must select the applicable legal entities for this feature. This is a multi-select option but, in my example, I will only configure tax for the “DEMF” legal entity.

    We now come to the actual setting up of tax rates. In the following screenshot I have created a new tax code name “DE-STD” to hold the normal German VAT rate (19%).

    Tax code set up

    Once I save the record, additional fields open up with additional details. As the following screenshot shows, I use the Add button to add a new rate of 19%.

    Tax rate set up

    Next, I set up a tax group named “DE-STD” but in this example, I have used the Manage Columns button to add the Delivery terms field to the line.

    This is a good example of we can use other data fields on the source document to determine tax.

    In this case, tax is calculated, if the order header delivery terms are “EXW”.

    Tax group set up

    Lastly, I create a new tax item group, as shown below, to complete the set up.

    Tax item group set up

    Publish tax Feature

    Our basic set up is now complete and it is time to publish it.

    Change tax feature status

    To change the status of a tax feature, you must click on the Change status on the version. First you must complete the feature and then publish it.

    Configuring the Legal Entity

    Tax calculation parameters

    For the tax calculation service to work in D365F&O, we must first make some configuration under Tax / Tax configuration / Tax calculation parameters.

    First, we must enable the integration by ticking the Enable tax calculation service.

    Secondly, we must link the feature we created earlier to this legal entity. This is done by selecting the “DEMF” feature in the Feature setup name field.

    Lastly, as the below snip shows, we must decide which business processes the tax calculation applies to. If a business process is not selected, the calculation will fall back on the inbuilt logic.

    Business processes using tax calculation

    Once you select the “DEMF” feature in the Feature setup name field, a dialogue pops up allowing you to enter missing information for settlement period and ledger posting group. This is information which is not recorded in the tax calculation configuration.

    Once you have entered the required information, data is synchronised, and a synchronisation log is created in a spreadsheet as shown below.

    Tax data synchronisation is successful

    Now, when I go to Tax / Indirect taxes / Sales tax / Sales tax codes, the “DE-STD” tax code has now been created in D365F&O.

    Putting it All Together

    We are now going to create a sales order and have the tax calculation service calculate tax. In the “DEMF” legal entity I create a new sales order to the customer “DE-011 Northwind Traders”.

    As you can see from the below screenshot, the delivery terms are “CIF”.

    Create sales order dialogue

    This is important because, if you remember, we set up our tax determination rule to use “EXW” delivery terms in the beginning.

    I now add a sales order line for the product “D0004 Kenya beans…” and the sales tax group and item tax group are set for “DE-STD”, which are the codes I created earlier, as shown below.

    Sales order line with tax groups

    However, when I click on Financials / Sales tax on the line ribbon, the tax calculation is empty as the screenshot shows.

    Empty tax calculation

    This is because the tax calculation rule, we created earlier, was determining tax based on the delivery terms on header level – not on the line level.

    Therefore, I change delivery terms on the header from “CIF” to “EXW”.

    When I go back and look at the tax calculation on the sales order line, there is now 19% tax calculated on the line level, as expected, as the below screenshot shows.

    Tax calculation complete

    This is essentially how the tax calculation service works. In future posts, I will take a look at other features such as using multiple tax registration numbers in a single legal entity.

  • Order Events in Dynamics 365 Supply Chain Management

    Order Events in Dynamics 365 Supply Chain Management

    For many businesses it is quite important to be able to track who did what, when, to a sales order mainly to understand the root cause when something has gone wrong.

    Luckily, Dynamics 365 Supply Chain Management (D365SCM) has a feature called order events that allows us to track changes to sales orders on a very granular level.

    Configuring Sales Order Events

    By default, D365SCM does not track sales order events so we must explicitly configure what we would like to track. This configuration is done under the menu point Sales and marketing / Setup / Events / Order events.

    Order events configuration

    When you configure order events, you must decide if the configuration is for:

    • a specific user.
    • a group of users.
    • all users.

    In the above example I am configuring order events for a group of users called “Order-T”. User groups are set up under System administration / Users / User groups.

    As you can see, I have selected all event types to be tracked. Obviously, this configuration is different for each installation of D365SCM and individual scenarios. For instance, if you are not using the Credit management module, some of the events such as Check hold are not applicable.

    With configuration done, it is time to create a new sales order.

    New sales order created

    Now that the sales order has been created, we can go to Sales and marketing / Inquiries and reports / History / Order events. As you can see from the screenshot below, a “Create sales order” event has been logged for sales order number “002472”.

    “Create sales order” event

    Now we go back and add an order line to the sales order as shown below.

    Add sales order line

    When we look back into the order event log, as shown in the below screenshot, a “Modify sales order” event has been created.

    “Modify sales order” event

    If I go back to the sales order and change sales price from $1,900 to $1,800 the change is tracked and displayed in the event log as shown below.

    “Sales line price override” event

    If a sales order taker is taking enquiries from a customer on a specific sales order, he or she can look up order events for that specific order by clicking on Order events in the View section of the sales order header ribbon.

    Lastly, I would like to point out that to protect system performance, order events must be cleaned up periodically. This is done under Sales and marketing / Periodic tasks / Clean up / Order events cleanup.

    I hope the above introduction to order events show how easy and useful it is to track order events in D365SCM.

  • Working with the Inventory Visibility Service for Dynamics 365 Supply Chain Management (part 2)

    Working with the Inventory Visibility Service for Dynamics 365 Supply Chain Management (part 2)

    In my previous post in this series, I looked at how we could use Power Automate to call the Inventory Visibility service. In this part, I create a Power Apps app to show the result of the query.

    Inventory On-hand Query App

    To keep it simple, I have created an app that allows the user to select a warehouse at the top of the screen. The site is derived from the selected warehouse.

    Once the warehouse has been selected, the user can select a product from the list and click on the arrow to see on-hand inventory. The following screenshot shows the result.

    Inventory Visibility Query Result

    As you can see from the above, there is 293 pcs on hand for product 1000 in warehouse 11 at site 1.

    So what did I need to do to query the Inventory Visibility service from the app?

    Call to Power Automate flow from app

    On the OnSelect event on the arrow in the gallery, I have added the above code. In the code I set a variable called QueryResultJSON with the result of the on-hand query.

    The Power Automate flow is invoked using the .Run() method with parameters from the warehouse drop-down control and the selected product in the gallery.

    Lastly, once the Power Automate flow has returned the result, I navigate to the QueryResult screen where I use the QueryResultJSON variable to display the result (293 pcs).

    Obviously, this is a very simple example, but it shows the power of being able to query and interact with inventory in Dynamics 365 Supply Chain Management in real-time.

  • Working with the Inventory Visibility Service for Dynamics 365 Supply Chain Management (part 1)

    Working with the Inventory Visibility Service for Dynamics 365 Supply Chain Management (part 1)

    As you probably know, Dynamics 365 Supply Chain Management (D365SCM) now comes with a hyperscale microservice that allows external systems to interact in real-time with inventory in D365SCM. The service is described in more detail here.

    In this two-part article, I am going to explore how we can call the service and use the data in an external app (Power Apps). In this first part, I will be looking at how to call the service through its inbuilt REST API.

    Before I get to call the service, I need to install and configure it. Once the service has been installed and configured, you can use the instructions in this article to start calling the API.

    In my example, I would like to create an app that shows me available inventory for a specific combination of organisation, site, warehouse and product.

    Instead of making the call directly from the app, I create a Power Automate flow that makes the call and returns the result as a JSON payload to the app as shown in the following screenshot.

    Power Automate Flow Calling the Inventory Visibility Service

    As you can see, the flow is invoked by a Power Apps app and will end by responding back to the app.

    The first action takes the product ID (ItemID) as a parameter from the app to use in the on-hand query.

    The second action calls Azure Active Directory (AAD) to retrieve an access token based on the configuration I made when installing the service as shown below.

    Retrieve Access Token from Azure Active Directory

    The response from AAD is in JSON format so in the next action I parse the JSON to get the actual access token for use in the next step.

    In the next step I use the access token retrieved from AAD to get an access token from the service as shown in this screenshot. The variable used in the client_assertion attribute is the AAD access token retrieved above.

    Retrieve Access Token from Inventory Visibility Service

    Please note that you may get and error 307 (temporary redirect) when calling the service. In the response header from the service, using the Location key, you can find the actual URL pointing to the service endpoint.

    Again, the response is in JSON format, so we parse this, but now we have the access token we need to actually query the service.

    In the last action I now query the service to retrieve on-hand inventory for organisation=usmf, site = 1, warehouse = 11 and product = 1000 as shown here.

    Onhand Inventory Query

    Obviously, when I create the app in the next part of this series, I will extend my flow to take site and warehouse as parameters and use these as variables in the query.

    This is what the result of the query looks like:

    [

      {

        “productId”: “1000”,

        “dimensions”: {

          “siteid”: “1”,

          “locationid”: “11”

        },

        “quantities”: {

          “fno”: {

            “arrived”: 0,

            “availordered”: 1265,

            “availphysical”: 293,

            “deducted”: 1,

            “onorder”: 76,

            “ordered”: 1048,

            “physicalinvent”: 293,

            “postedqty”: 294,

            “quotationreceipt”: 13,

            “reservordered”: 0,

            “reservphysical”: 0

          },

          “iv”: {

            “ordered”: 0,

            “softreservphysical”: 0,

            “softreservordered”: 0,

            “reservphysical”: 0,

            “reservordered”: 0,

            “orderedtotal”: 1048,

            “onhand”: 293,

            “openorder”: 76,

            “onhandavailable”: 293,

            “availabletoreserve”: 1341,

            “inventorysupply”: 1341,

            “inventorydemand”: 76

          },

          “iom”: {

            “onhand”: 0,

            “onorder”: 0

          },

          “sap”: {

            “unrestricted”: 0,

            “qualityinspection”: 0

          },

          “pos”: {

            “inbound”: 0,

            “outbound”: 0,

            “availquantity”: 293

          }

        }

      }

    ]

    As mentioned, in the next part in this two-part series, I will create an app that calls this flow and presents the result in a meaningful way.

  • Using Derived Test Cases in RSAT

    Using Derived Test Cases in RSAT

    To provide the best possible test coverage and to test breaking scenarios, we need to test the same process with multiple variations on data – also data that will deliberately break the test case.

    Luckily, in RSAT we do not need to record a new test case every time we would like to add a new test data scenario.

    Instead, we can leverage the derived test case feature.

    A derived test case in RSAT is essentially a copy of an existing test case with a separate parameters file holding the test data variation.

    The following screenshot shows a test plan with three test cases loaded into RSAT. As you can see, test case #4027 has the Derived flag ticked since it is a derived test case from test case #4018.

    Test plan with a derived test case in RSAT

    Creating a Derived Test Case

    To create a new derived test case, you select the original test case and click on New / Create derived test case in the menu at the top of the screen.

    Test plan with newly added derived test case

    As the above screenshots shows, a new test case has been created from the original test case (#4018) named #4028.

    Clicking on Parameters in the menu opens the Excel file holding the test case parameters as shown below.

    Derived test case parameters (before change)

    The warehouse used in the original test is “11”. Instead, we would like to test how the system reacts, if we select an illegal value (“33”) in the warehouse field as shown in the new scenario below.

    Derived test case parameters (after change)

    In this scenario we are providing the system with an invalid warehouse (“33”) for site (“1”) and therefore the test case should fail.

    The derived test case can now be executed by clicking on Run in the menu.

    Test case failed – as expected

    As you can see in the above screenshot, the test did indeed fail.

    To investigate further, click on Open / Open recent test runs the menu. This brings up the details of the test case run as shown below.

    Test case results are captured in Azure DevOps

    As you can see, the error message clearly indicates that the test case attempted to use an illegal value in the warehouse field.

    As you close the RSAT tool it will warn you that not all data is saved to Azure DevOps. This is because a derived test case is created in RSAT locally and not Azure DevOps and therefore you need to upload the artefacts to Azure DevOps.

    Remember to upload new artefacts to Azure DevOps

    Conclusion

    Derived test cases is an efficient and powerful way to expand the test coverage for a given process across multiple data scenarios and will help ensure that the system is able to cope with intended as well as unintended use cases.

  • Passing Legal Entity Context to an Embedded Power Apps App in Dynamics 365 Finance and Operations

    Passing Legal Entity Context to an Embedded Power Apps App in Dynamics 365 Finance and Operations

    With Platform Update 43 it is possible to pass the current legal entity context from Dynamics 365 Finance and Operations (D365F&O) to an embedded Power Apps app.

    In this blog post I will look at an example where I display fixed assets for a given legal entity. The legal entity is passed from D365F&O when I open the app.

    To capture the legal entity passed from D365F&O, I add the following code to the OnStart app event:

    Code in OnStart event

    This code captures the “cmp” parameter passed from D365F&O and puts it into a variable named “FinOpsLegalEntity”.

    I have added two data sources to the app:

    App data sources

    The FixedAssetsV2 data source points to the Fixed Assets data entity in my instance of Dynamics 365 Finance and Operations (D365F&O) and the CachedAssets is a collection to hold the assets I fetch from D365F&O.

    To fetch and cache the fixed assets in the app, I also add the following code to the OnStart event:

    ClearCollect(CachedAssets,Filter(FixedAssetsV2,Company = FinOpsLegalEntity))

    This code fetches all fixed assets from D365F&O where the Company field value is equal to the legal entity value that was passed from D365F&O when the app what started.

    To display the fixed assets, I have fetched and cached from D365F&O, I add a gallery (Gallery1) to my app as shown below.

    Gallery added to app

    As you can see, the Items event contains the following code to populate the gallery:

    SortByColumns(CachedAssets,"FixedAssetNumber")

    This code uses the CachedAssets collection to populate the gallery sorted by the FixedAssetNumber column.

    Lastly, I add a text field to display the legal entity passed from D365F&O as shown in the below screenshot.

    Text field with legal entity value

    As you can see, the field contains the FinOpsLegalEntity variable in the Text event to display the content of the variable.

    I save the app and copy the app ID GUID. Now we are ready to embed the app into D365F&O.

    Personalise dashboard

    In this example I would like to embed the app as a tile on the dashboard, so I open the personalisation dialogue and select Add a page from the dropdown menu.

    Add a page dialogue

    Next I choose Power Apps from the list.

    Add Power Apps app dialogue

    Lastly, I give the tile a name and paste the app ID GUID into the App ID field.

    Asset list tile on the dashboard

    As you can see, the dashboard now contains a new tile named Asset list.

    When I click on the tile, the app starts and as you can see, the legal entity context (usmf) has been passed to the app.

    Asset list filtered by legal entity

    This was a very simple demonstration showing how easy it is to pass the legal entity context to a Power Apps app and use it to filter data.

  • Extend Dynamics 365 Finance and Operations Workflows with Business Events

    Extend Dynamics 365 Finance and Operations Workflows with Business Events

    Back when Business Events were introduced in Dynamics 365 Finance and Operations (D365F&O), a slightly overlooked use case was the ability to extend inbuilt workflows to external endpoints such as Power Automate.

    In this blog post I explore how to use a Business Event to execute the approval process in Power Automate for a general ledger journal.

    Designing the Inbuilt Workflow

    To kick things off, I create a simple general ledger journal approval workflow using the inbuilt designer as shown below.

    General ledger journal approval workflow

    As you can see, the workflow is quite simple in this example and only contains a single approval activity. Once I save the workflow, Business Events representing the workflow elements are automatically created in the catalogue:

    Workflow elements in the Business Events catalogue

    Connecting the Business Event to Power Automate

    Since we are going to make the actual approval happen in Power Automate, the Business Event we are interested in is in the category called “Workflow workitem” as this is the category used for the actual work items in the workflow.

    To connect the business event to Power Automate, we need to set up an endpoint in the Business Event catalogue. Before you can set up an endpoint, you need to create the Power Automate flow that the endpoint will point to.

    As shown below, I create a new flow with the “When a Business Event occurs” trigger on the D365F&O connector.

    Power Automate flow trigger

    Once the flow has been saved, you can use the flow URL to set up the Business Event endpoint.

    When the endpoint has been created, you can activate the business event.

    Power Automate Approval

    Now the Business Event is linked to the Power Automate flow, and we need to design the actual flow to replace the inbuilt approval process.

    Parse Business Event payload JSON

    After the trigger, the first step in the flow is to parse the JSON supplied as a payload with the Business Event. This allows us to reference workflow data later in our flow.

    Capture workflow instance ID as a string

    Next we want to capture the workflow instance in a string variable to allow us to query and update the workflow item later in the flow.

    Check the state of the workflow

    Before we send the workflow item for approval with the user, we need to ensure that it is in a state that allows for approval. In this case we are using the “Execute action” action on the D365F&O connector in Power Automate calling an action named “WorkflowWorkflowItems-validate” with the workflow instance as a parameter.

    Acting on workflow state

    If the response from the check is “True”, the workflow is in a ready-state for approval actions to be applied.

    Configuration of the approval action in Power Automate

    In Power Automate I use the Approval action to start the approval process. In this example I use data captured in the payload (see above) to fill in the Approval action properties.

    Firstly I use the “WorkflowUserEmail” value to assign the approval request to the user assigned to the workflow item.

    Subsequently, I fill in the details of the message with “WorkItemOwner” (user) and “WorkflowStepInstruction” (instructions from the workflow item).

    Lastly, I use the “LinkToWeb” value for the Item link property. This allows the user to click on the link in the approval request and jump straight to the ledger journal in D365F&O.

    Once the user has approved or rejected the approval request, we need to update the workflow item with the result.

    Update workflow item with approval result

    As you can see from the above, I am using the “WorkflowWorkflowItems-complete” action for this. I am using the “Outcome” property from the Approval action to set the outcome in the workflow item.

    The possible outcomes for the workflow item are available in the payload and can be used in the approval request.

    I am using the “Response summary” from the approval request in the Comment field and the “WorkItemOwner” from the payload as the RunAsUser.

    Testing

    So now it is time to test our configuration. To get started I create a new general ledger journal and select Submit from the ribbon:

    Submit general ledger journal for approval

    Assuming that everything is configured correctly, the user now receives an approval request. In my case I am using the Approvals app in Teams (who would have guessed?).

    This screenshot shows the approval I receive in Teams:

    Teams approval request

    The same request is also sent by e-mail to the user.

    From the request I can approve or reject the item, but I can also click on the link to jump directly to the general ledger journal.

    When looking at the workflow history from the general ledger journal in D365F&O, we can now see that the workflow item has been approved:

    Workflow item history

    As I have showed in this blog post, we can extend inbuilt workflows using Business Events and, in this case, Power Automate. Beyond external approval, this opens up a range of options for external data processing as part of a workflow.

Create your own website, free on WordPress.com.Create your own website.
Start free