As C/AL is my number one language to code, I wanted since last summer to give it a try to Microsoft Flow. And as Twitter is one of the top 3 applications I use on my phone I wanted to see if I can get an MS Flow bring the tweets in my favorite environment, Dynamics NAV.
After a few trials and tweaks my flow brings twits in NAV:
If you want to try it out this is what you need:
- a Dynamics NAV instance with public IP. I used an azure machine loaded with Dynamics NAV 2017
- web services for entities you want to create or update via MS flow
- a Microsoft or work account to connect to flow.microsoft.com
- a Twitter account
To allow MS Flow to talk to both Twitter and MS NAV we need to set up appropriate Connections in MS Flow:
The connection to NAV looks like this:
For usename and password create a NAV user and set a password. On the instance you want to connect set a credential type = NAVUserPassword.
For twitter connection user your twitter user id.
To support the Flow, I needed 2 tables and 2 pages:
- a table Tweet and a page Tweets (exposed as web service) to support the tweets
- a table Last Tweet to record the last tweet id coming into NAV and a page to be able to update this last tweet id, so the flow does not collect again the same tweets but only new tweets published after the last tweet brought to NAV
And this is what the flow is doing:
- Start with a recurrence action:
- Get the last tweet id by using the NAV connection:
- Set up the search for tweets action:
- Insert a new record in the NAV Tweet table by using a NAV connection and mapping twitter fields to NAV fields:
- Update “Last Tweet” table with the last action in the flow:
And this is how the flow looks like:
The C/AL code is included here.
Thanks for reading. Enjoy Flowing!