Use Data Entities in Dynamics 365 Finance & SCM to expose Business Logic

Entities in Dynamics 365 Finance & Supply Chain are not only good to access data. Entities can also be used to execute X++ business logic from 3rd party applications like Power Automate.

For example a table contains shipping carrier records. A Carrier has a Name and Description. The name is the primary key. The combination of Name and DataAreaId makes a record unique at the database.

Carrier Table

There is also an entity to access the data.

Carrier Table Entity

An Action is a piece of X++ logic exposed via entity. This example sets the Carrier as default value for a customer:

public class DMOCarrierTableEntity extends common
{
/// Set as default
/// Customer Account
[SysODataActionAttribute('SetDefault', true)]
public void approve(CustAccount _custAccount)
{    
    ttsbegin;
    CustTable custTable = CustTable::find(_custAccount,true);
    custTable.DMOPreferredCarrier = this.Name;
    custTable.update();
    ttscommit;
}

Such an action can be called via Power Automate:

Call custom action via Power Automate

Mini Webcast Series: Dynamics 365 FO Connector for Power Automate

Power Automate (aka. Flow) is a great solution for process automation. It is very useful to realize cross-application processes. Power Automate features a wide variety of tasks and connectors. It also comes with a connector for Dynamics 365 Finance and Supply Chain Management. It can be used to trigger a flow, interact with data and execute business logic in D365 FO from within a flow. You can find all videos on my YouTube Channel.

Part 1: Trigger a Flow with Business Events

Business Events in Dynamics 365 Finance and Supply Chain Management are use to interact with other systems. For example you can send message to Azure Event Hub but also to Power Automate. There are some specific events but you can also use change-based alerts in Dynamics. This video shows how to trigger a flow using such a business event.

Business Events can trigger Power Automate flows

Part 2: Interact with data in Dynamics 365 Finance and SCM

The Connector for Dynamics 365 FO uses entities to interact with data in the ERP system. You can create new records, read, update and delete records. Here is an example where Power Automate receives data from Forms Pro and create a new customer in Dynamics 365 FO.

Create new records in Dynamics 365 FO from Flow

Part 3: Execute Business Logic in Dynamics 365 Finance and SCM

The Dynamics 365 FO Connector in Power Automate supports to execute business logic by calling actions on entities. Here is a video how to approve a Bill of Materials in Teams and execute the Approval logic via Flow.

Execute Business Logic from Flow

Filter on NoYes field in Dynamics 365 Flow Connector

The Dynamics 365 connector in Power Automate provides the basic operations to interact with your Dynamics 365 FO instance. You can create new records via flow (e.g. a new Customer), read, update and delete records (e.g. Sales Order Lines) and retrieve the list of available entities.

Dynamics 365 Finance and Supply Chain Connector in Power Automate
Dynamics 365 Finance and Supply Chain Connector in Power Automate

The connector uses OData to interact with the entities in Dynamics 365 FO. Therefore, it also supports OData syntax for filter expressions. If you want to filter on a boolean Extended Datatype like NoYes and try to use “Yes” or “1” or true it will not work. Dynamics 365 has its own Datatype that comes from the entity definition Microsoft.Dynamics.DataEntities.NoYes .

One Time Customer in Dynamics 365 Finance
One Time Customer in Dynamics 365 Finance

For example, if you want to get all One-Time Customers from Dynamics 365 FO, use the Dynamics 365 connector and choose the action “List items in present Table”. Use the Customers entity. To filter on a NoYes field like One-Time Customer you have to use the following syntax:

  • IsOneTimeCustomer eq Microsoft.Dynamics.DataEntities.NoYes’No’
  • IsOneTimeCustomer eq Microsoft.Dynamics.DataEntities.NoYes’Yes’
Filter on NoYes field in Dynamics 365 Finance Connector
Filter on NoYes field in Dynamics 365 Finance Connector

Sixth and last week under third Lock-Down in Austria (8. Feb. 2021)

The 3rd Lock-Down is more or less over. Restaurants and Bars are still closed. Kids are allowed to go to school but are separated in shifts. Also mandatory self-tests are required to attend a class. If for what reason parents don’t wont to get their kids tested they have to attend via Home-Schooling. Retail shops will open as well but require 20 m² per customer. FPP2 mask are now also mandatory in shops and public transport. If you wan’t to get your hairs cut, you have to have a negative Covid-19 not older than 48 hours.

However, there is great concern about the end of the lock-down. The South-African Covid-19 mutation is now established (mainly in Tirol). The British mutation is becoming mainstream. The self-service tests at School seam to be not very effective.

Daily infections in Austria at the end of the third lock-down (Source: https://covid19-dashboard.ages.at/)

Covid-19 map shows reduced risk at Vienna

Since a very long time the traffic-light encoded map doesn’t only show everything at high-risk red but Vienna is now displayed as still very-risky orange. However, there is still not distinguishing between districts within a state.

Stop-Corona App

The Stopp-Corona App by the Austria Red Cross is now compatible with 11 other EU countries. Users can now use the App to warn people from other EU countries using their foreign App. The app has been developed during the first Lock-Down in spring 2020 but isn’t so popular in Austria.

Stopp-Corona App

COVID-19 in Computer Games

Corona can also be found in actual PC Games like Euro Truck Simulator and American Truck Simulator. SCS has set up a 0-damage vaccine delivery challenge in both games. The goal is to deliver 7 times the Covid-19 vaccines without any damage to the cargo.

Virtual Vaccine Delivery Challenge in ETS and ATS

Fifth week under third Lock-Down in Austria (1st. Feb. 2021)

We’are in the fifth week in the third Lock-Down in Austria. Better called a not-so-lock-down because a recent study conducted by Invenium shows that the actual lock-down reduces the mobility of people only by 20 percent. While in at the first Lock-Down in Spring 2020 the travelling behavior decreased by 75 percent. In general, the actual Lock-Down from 26th December 2020 till today isn’t very effective any more. Schools are (more or less) closed. There is no education on site but families can bring their kids for day care and in some schools this are 2/3 of the regular class.

Source: https://covid19-dashboard.ages.at/

Popular Petition

This week the period for support on three popular petitions ended. The first petition want’s to establish ethic education at school for all students no matter if they attend any religious education as well. The second petition addresses the well-being of animals, especially those in the food industry. The last one requests a law in the constitution that vaccination must not be mandatory. All petitions can be signed online if you are using the governments mobile signature app

Popular petitions can be signed online using the signature app

Fun fact, two other petitions can be supported. One for Mandatory-Vaccination No! and another for Mandatory-Vaccination Yes! If you like trolling, you can support both 🙂

Mandatory vaccination yes ! no ! .. whatever

Vaccine Information Registration Form

The government has put up a web site to get informed about vaccinations. <sarcasm>Because Austria is such a huge country, each state has now its own information registration platform.</sarcasm> You have to provide name, age, contact information, preconditions (sometimes depending on your state), etc. You don’t get an appointment, but you will be informed if you can apply for an appointment or if something in the vaccination plan is changing.

Online Exams

The second semester under Covid-19 restrictions is coming to an end. Like in summer there is no education at the university campus. Lectures are done remote and exams as well. In most cases you have to attend a Zoom meeting and present an ID card. The exam itself is an online test. Sometimes you have to write and upload a PDF document, sometimes you can put your answers direct into a questionnaire. It is said that the university management is not so happy with this online exams. But for me its very convenient to take the exam at home. Hopefully we can keep this modus operandi in the future for exams.

Intellectual Property Online Exam via Zoom

Fourth week under third Lock-Down in Austria (24.1.)

We’re still in Lock-Down since Christmas and the actual Lock-Down has been extended at least till 8th February. The number of daily new infections is stable at under 2000. This is way too much but is not decreasing. So we keep lock-down for weeks and weeks now.

Source: https://covid19-dashboard.ages.at/ (24.1.2021)

Mask Upgrade FFP2

Masks: Scarf Early 2020 – Face-Mask Mid / End 2020 – FFP2 2021

Starting January 25th, it is mandatory to wear a FFP2 mask in stores and public transport. An FFP2 mask provides a better filtration effect. This shall help to fight the new Corona mutations from Britain and South-Africa which seam to be more infectious.

Remote Monitoring for Covid-19 patients

A corona infection can turn into a sever problem very quickly. However, it not feasible to keep every positive tested patient at the hospital. The Medical University of Innsbruck is remote monitoring Covid-19 patients using skin sensors and apps. The sensors keep track of temperature, O² saturation, breathing and pulse. This system was already in use for patients with heart problems and was now adapted for Corona. Therefore, patients can stay at home as long as possible but if the situation becomes critical the medical staff gets informed.

Vaccines: Mayors push themselves forward

Austria started to vaccinate people. Because only a very limited amount of vaccines are available. Approximately 1/3 of all Corona deaths in Austria were at retirement homes. Therefore, the governments plan states that high-risk people 80+ in retirement homes shall be vaccinated first. However, many mayors found a way to get a shot although they are not old or high-risk. In many cases the mayors are also the head of the retirement homes in their city. Many argue they have been on site “by accident” and didn’t want to let the vaccine go to waste.

Corona Map Paused

Since Summer 2020 the Austrian government is maintaining a traffic-light color encoded map to visualize the Covid-19 situations in parts auf Austria. Green stands for low risk, yellow medium risk and red high risk. A committee is evaluating the situation every Thursday and presents the new map in Friday. However, since the beginning of the second wave in later autumn 2020 the map is deep red for all parts of Austria. Because the number of infections per day remains at a very high level for weeks, it was decided to pause the map.

Source: https://corona-ampel.gv.at/ (24.1.2021)

Extend Dynamics 365 Dual Write Solution

Dual Write is a Power Platform based solution to synchronize Dynamics 365 Finance and Supply Chain with Dynamics 365 Customer Engagement in real time. I’ve uploaded a Youtube Video that shows Dual Write in Action. The default solution comes with a set of synchronization entities like Products, Customers, Vendors, Quotations, Sales Orders and Invoices. In a Dynamics 365 project you typically need to add additional information in both applications.

In this example a customer shall have a preferred carrier. The carrier (e.g. UPS, DHL) will be stored in a main table. The customer entity will have a reference to set the carrier. The corresponding account entity in Dynamics 365 Sales will have the same lookup field and preferred carrier settings will be synchronized between Finance and Sales.

Carrier in Dynamics 365 Finance and Supply Chain Management
Carrier in Dynamics 365 Finance and Supply Chain Management

Extend Dynamics 365 Finance / SCM Data Model

For Dynamics 365 Finance / SCM create the necessary artifacts in Visual Studio:

  • A carrier table with a mandatory Name and Description field. Also create a primary index based on the Name.
  • An entity to make the carrier table accessible from external applications.
  • An extension of the CustTable with a Carrier field and a table reference from the CustTable to the Carrier table.
Dynamics 365 Finance / SCM Solution for customers preferred carrier
Dynamics 365 Finance / SCM Solution for customers preferred carrier

Save, compile and create a deployable package. Upload the package to your projects LCS asset library. After the package was validated, deploy the package to your target environment. After the package was deployed, go to Data Management Workspace > Framework Parameters > Entity settings and refresh the entity list.

Extend Dataverse (aka. Common Data Service) Entities

Navigate to https://make.powerapps.com and switch to your target environment. Go to Data > Tables and create a new table for the carrier. The table shall match the carrier table in Dynamics 365 FO. Make the Name field as mandatory primary field and add a second optional text field for the Description. Add a lookup field to the existing company table to match the DataAreaId that will come from Dynamics 365 Finance. Note that PowerApps will add a lot of other fields like owner, created, etc. as well.

Create a carrier entity in the Dataverse (CDS)
Create a carrier entity in the Dataverse (CDS)

Find the account entity that was created by the Dual Write solution. Add an addition lookup field called Carrier that references the newly created carrier table.

Carrier lookup in the account entity
Carrier lookup in the account entity

Customize the accounts form in Dynamics 365 sales

In PowerApps > Data go the accounts table and switch to the forms tab. There go to the Main form that is used in Dynamics 365 Sales to work with accounts. Click on the Name of the form, this will open the forms designer.

Dynamics 365 Dataverse Account entity
Dynamics 365 Dataverse Account entity

In the PowerApps designer add the Carrier field to the form. Save the change and publish the customized form.

Add carrier to Dynamics 365 Sales Account Form
Add carrier to Dynamics 365 Sales Account Form

Map the Carrier Entity from Dynamics 365 Finance to the Carrier table in Sales

In Dynamics 365 Finance open the Data Management Workspace and go to Dual Write. Create a new table mapping. Map the Carrier entity from Dynamics 365 FO with the Carrier table form the Dataverse.

Create a new table mapping in Dynamics 365 Dual Write

Next map the Carrier Name fields and the Carrier Description fields. Save and start the initial synchronization.

Map Dynamics 365 FO entity to Dynamics 365 Sales table

Check if the synchronization was successful. Open https://make.powerapps.com in a browser and switch to your target environment. At the left menu go to Data > Tables. Click on the Carrier table and switch to the Data tab. You should see the same carrier like in Dynamics 365 Finance.

Add the Carrier Lookup field to CustomverV3 mapping

Stop the synchronization of the CustomerV3 to account. Go to table mappings and refresh the tables. This will load the table schema from the Dataverse with the new carrier lookup field. Create a new mapping from the Carrier in Finance to the Carrier field in Dataverses entity. Save the mapping definition as a new version. Restart the synchronization and make sure there are no errors.

Mapping carrier fields in Dual Write
Mapping carrier fields in Dual Write

Now you should see and edit the Carrier in Dynamics 365 Finance as well in Dynamics 365 Sales. Changes made in any of the two products will be synchronized.

Preferred Carrier field in Dynamics 365 Finance and Supply Chain Management
Preferred Carrier field in Dynamics 365 Finance and Supply Chain Management
Mapped and synchronized Carrier field in Dynamics 365 Sales
Mapped and synchronized Carrier field in Dynamics 365 Sales

Limitations

Dual Write has some limitations regarding the number of lookup fields. If you come across an error during the synchronization you may need to remove some of the lookup fields from the Dual Write table mapping.

Third week under third lock-down in Austria (16th January ’21)

We are in the third week of the third lock-down in Austria. Mass-testing to end lock-down for negative tested people has been canceled and we are at least under lock-down till 24th. However, with the increased distribution of the more infectious British COVID-19 strain it is not sure if the lock-down will end or be continued. We are looking at the situation in Ireland where the infections are skyrocketing because of the new COVID-19 strain.

Massive spike of infections in Ireland is possible related to the new COVID-19 strain from Britain
Massive spike of infections in Ireland is possible related to the new COVID-19 strain from Britain
Source: https://coronavirus.jhu.edu/map.html

Right now the number of infections in Austria are stable at a high value.

Infections in Austria
Infections in Austria, Source: https://covid19-dashboard.ages.at/

Last PASS SQL Saturday Vienna 2021

Due to the insolvency of PASS head organization this was the last PASS SQL Saturday in Vienna. The local chapters can operate independently and PASS Austria may exist as Data Community Austria. Because of the COVID-19 pandemic this SQL Saturday was held virtual via Teams. Hopefully we will have a similar event with great content in the future.

Attending the virtual SQL Saturday Vienna 2021 from my home office
Attending the virtual SQL Saturday Vienna 2021 from my home office

Announcement: Global Azure Bootcamp 2012

The Global Azure Bootcamp 2012 will be held virtual this year as well. GAB was one of the first events last year that decided to switch to an virtual form. This years GAB will be virtual as well.

Mandatory Pre-Registration for visiting Austria

Anyone who is coming to Austria has to fill out a registration form. This applies also to Austrians coming back home. You have to provide personal information like name, nationality, etc, where you will stay and where are you coming from. Nevertheless, the 10 day quarantine with an option to test free after 5 days is still mandatory (with some exceptions)

Travel Registration Form for visiting Austria
Travel Registration Form for visiting Austria

Second week under third Lock-down in Austria (11th Jan. ’21)

Since 26.12 we are still under lock-down. It looks like Christmas didn’t cause a rapid spike of infections. However, the goal from the second lock-down to reduce the second wave under 1000 infections per day is still not reached. The actual situation, restaurants and retail closed but offices allowed keeps the curve constant at ~ 2000 infections a day. After the holidays, today is the first “real” working day.

Source: https://covid19-dashboard.ages.at/

Mass-Tests canceled

The third lock-down is scheduled until 24th January. The government wanted to provide the option get tested on 15th, 16th and 17th of January and again provided a website to register for a test. With a negative COVID-19 test it should have been possible to access restaurants and events. However, it was not clear who would have been be responsible to check if a customer has a valid negative test and for how long a negative test result would be valid. So the opposition parties threatened to slow down the process at the Bundesrat (second chamber of parliament) by a one-time veto and the government decided to drop the earlier mass test.

COVID-19 Mass-Test canceled

SQL Saturday virtual Event

COVID-19 killed another organization, PASS (professional associates for SQL Server) is insolvent. However, the local chapters like PASS Austria are still operable. This years SQL Saturday Vienna will be held online. Following a good tradition, SQL Saturday will be held on Friday 15th January.

Labor Minister resigned

CTRL+C and CTRL+V are very helpful shortcuts, but if you write a academic document you need to cite. The labor minister is accused of plagiarism and resigned on Saturday.

First week under third Lock-down in Austria (1.1.2021)

We’re back in a hard lock-down. In contrast to the second lock-down in November and December 2020 this one is a proactive lock-down to keep the infections after Christmas under control. Started on 26th December we are under an all-day curfew and non-essential business are closed. Up to now, the impact of the new GB mutation which is more infectious is unclear. Hopefully this will prevent uns from a third wave.

COVID-19 infections in Austria
COVID-19 Infections in Austria (Wave2) Source: https://covid19-dashboard.ages.at/

The last year was very challenging for all of us. COVID-19 killed approximately 1.8 million people, and many suffer from severe consequences of a COVID-19 infections. Actions taken to get the pandemic under control brought us into a economic and social crisis. However, from an IT perspective the good news are that COVID-19 boosted Digitization.

Something good in 2020

  • Microsoft Teams: 2020 was the year of Teams. Never ever was a Microsoft Product adopted so quickly by so many people and organizations. Thanks to the (very) hard lock-downs in Europe in spring, Teams was one of the few products that kept many organizations operable.
Microsoft Teams in 2020
2020 – The year of Teams
  • The Cloud: Those who didn’t understand the benefit of the cloud have learned it the hard way this year. The only way to scale up in a very short time is the cloud. No matter if it’s in a public or private cloud. But the situation in early 2020 showed that only the public cloud like Azure could handle the situation. When millions of people are forced to work from home, classic on-premises installations and VPN Gateways collapse.
  • Azure Region Austria: Microsoft announced to build two data centers in Austria. We will get our own Azure region. Typically our customers host their Azure Workloads in the West-Europe region. In the future we will be able to place the cloud workloads closed to the our customers.
  • E-Health: Digitalization and health care has never been a big issue in Austria and Digitalization projects like ELGA (electronic health file) was not very widely used. But COVID-19 boosted Digitalization in health care. We’ll get an electronic vaccination pass next year and e-prescription.
  • Home / Distance Schooling: It is said that the Austrian Education system is very old fashioned and stuck in traditions over decades. Over the last centuries E-Learning was explored from time to time but never ever taken serious. COVID-19 forced the education system to adapt to the situation. Universities also struggled to make exams remote compatible and came up with modern, naive and lazy solutions: The closest solution to a normal exam are Zoom-Meeting based exams, where you have to be online including audio and being watched through the webcam. Some Law-Schools found another way without all the fancy technology stuff. You get the exam online and have to upload the results within a given time, including a sworn declaration that you didn’t cheat. And some other lecturers replaced the classic exam by letting the students write an essay about some textbooks.
  • Bitcoin: Lucky you if you are a Bitcoin hodler 😉
Bitcoin skyrocketing in 2020
Bitcoin skyrocketing in 2020

“A very merry Christmas and a happy New Year Let’s hope it’s a good one”
– John Lennon, Merry Christmas