Tuesday, 14 August 2018

Using Global Variables with Retail Modern POS

I am using version 8 platform update 15. Since the POS development is locked out and extensions only is allowed. There are some limitations and a number of objects are not accessible.

I was trying to navigate to the customer search and allow the user to select a customer and return to the calling form. This was very challenging.

One possible solution I found is to use Global variables. I used the window object.

To do this, declare the window object as per screenshot. And then just set your object :

eg. window.MyVarName = WhatEverObject;


To get the value just invert it.


You can see how I have the customer object in debug.


Credit to one of my colleagues who suggested this solution.

Monday, 2 July 2018

Automated testing #MSDyn365FO Odata with Postman

In the last post I did a quick run through on using Postman for testing Odata services.

This post I will give some tips on how you can write automated tests using Postman.

Tip 1 – Parameterise as much as you can

Parameterise using the environment settings. It will make your collection portable to other projects.

Below is an example where we have the environments settings parameterised.


You can see how I used it here. Now I can utilise the same thing across requests.


Tip 2 – Write test scripts

Test scripts are very easy to work with. This is for demonstration purpose only. I will explain how you can retrieve the values in the returned json.

Take the example here, where we use the “get customer” odata service. It returns a nested array with the values.


You can write a simple test script to retrieve values. In the below highlighted box you can see that I am logging it to the console. I am not really testing much here.


The console will return the below. 


One bonus tip here. Just click on the snippet codes to get sample code from Postman. Really helpful.


Tip 3 – Automated testing

Usually you will have dependent requests. The first request in our example retrieved the OAuth token and saved it in the environment settings. For the second request to work, it must get a fresh token to authenticate.

To run the collection, click on Runner at the top left of the main window.


Once the runner window opens up. Select you collection or folder. Then click on Run button at the bottom.


Once complete, you get your result.


If you are new to all this. I would recommend taking a look at postman blog on automated testing.


Thursday, 28 June 2018

Testing #MSDyn365FO Odata with Postman

Last year I posted on using Postman. Things have changed since then and I need to update.


There is a good article that Microsoft has written which I followed without any issues.


Below are some screenshot incase you are a visual person like me.

In the environment set ups. It should looks something like this.


When you run it, you should get a response.


Once you got the token. You are good to go with your messages.

Below is the same example from the blog post.


You run into any problems, click on the console icon at the bottom. Should give you a bit more information.


If you get a 401 error. It is usually a typo. Make sure you got the spaces and backslashes correct. One simple character can drive you crazy.

Thursday, 7 June 2018

Import document handling (attachment) files #MSDyn365FO

Out of the box you have limited data entities for migrating attachments. If you search what is already in the AOT, you will see a few various examples. I suggest you look at the LedgerJournalAttachmentsEntity as it is the simplest and cleans to copy from. I wont go into detail but I will give a quick run down of what it looks like.

  1. Use the DocuRefEntity as your main datasource. It does most of the work for you.
  2. Set your table you want to import for as the child datasource
  3. Add the Key


You will need to add the postLoad method. There is minor code to update the virtual field FileContents.


Below is an export I did for the general journal attachments. The import zip structure should be the same way.

It will create the usual artifacts such as the excel, manifest and package header xml files. You will see a Resources folder under that.


If you drill down to the resources you will see the attachments. This is an export and it used the document GUID for uniqueness. The other thing is the extension isn’t added to the file name. When you are importing you are ok to leave the extension name.


The Excel file looks like this.


Hope it helps.

Wednesday, 9 May 2018

Top 5 tips for developing a Chatbot

This is different from my usual blog posts but I have been sitting on this for some time. I have been working with Chatbots for about 1 year now. Been on and off various engagements. So, I wrote something to make it a a bit clearer for those wanting to develop it and those wanting to know about it.

Chatbots are very trendy these days and thought I would write up some personal learnings I have made. Chatbots have existed for many years but the technology has been democratised like many things in Azure. You can literally build a bot for free of charge (of course you have to invest a bit of your time). A user would generally communicate through a chat window and with the addition of cognitive services, you get a really powerful tool.

Below are my top tips for when building your first chat bot.

1. A chat bot must have a purpose

There are a few forms of chat bots out there.

a) General Chatbots – Alexa, Google, Cortana, Siri, Watson. This is the big problem these major companies mentioned are trying to solve. Some are very similar and some are very unique in the way they are tackling the problem. A while back Alexa and Cortana have signed an agreement. This may seem odd at first but it benefits bot companies. Rather than competing with each other, their partnership offers them a greater reach.

This is not the area for every company. It requires huge investment.

b) Domain Specific and/or Task Specific – Some examples are Alarm (Wake me up at 7am tomorrow), Weather (What’s the weather today in Perth), Health (Natural health advice), Retail (Product recommender), Company Policies (QnA)

These are some examples but the application is endless. With the toolkits available you can build a chat bot that has deep knowledge about a specific domain or a specific task. If you can focus on solving a problem for the domain then the application has purpose.

2. Know your audience

Know your audience before you develop your chat bot. If you are developing a chat bot for business users, make sure to communicate to them at the same level. Don’t try to tell jokes or deviate from your purpose. Some would call this a personality but most business users don’t expect a personality when they are performing a task that is supposed to be simple.

However, if you are developing for a consumer market, you could add personality to your chat bot. Making the users experience less serious and a bit of fun. You could tell a random joke if the user asks. You could personalise the message and try to up sell.

3. Keep it up to date

A chat bot should be well trained and kept up to date to provide the user with the best possible answer. A stale chat bot will die a lonely death and be forgotten. Remember, users don’t uninstall a chatbot. They merely stop using the chat bot and loses its relevence.

4. Be helpful

If your chat bot does not know how to answer a question. Don’t say you don’t know and stop there. Offer suggestions or some kind of summary of what the chat bot can do. For example, a user may enter a topic that is unrelated. The chat bot can respond with “I don’t understand” but you can improve this response by being helpful. Tell the user what you can do. “I don’t understand but I can help with booking your leave”. We could provide buttons or dialogs for the user to enter one of these conversations.

5. Design your flow

This sounds obvious but many forget. Before you begin any development, even a prototype, design your conversation dialog. You will see how many ways you could achieve the same thing via a conversation.

Think of a chat bot for booking leave. You could provide a wizard type dialog. Asking various questions such as; What date, how many days, what type of leave etc. Alternatively you could just build language understanding to interpret a single sentence.

User: “Book me annual leave starting next Monday for 5 days”.

From this one line we could interpret the following:

a) Type of leave is Annual leave

b) Date – starts next Monday

c) Duration – 5 days

A bonus tip is to watch this youtube video. I learnt so much and made me reflect a number of things that I have done.


Take away quote that really resonated with me “Solve one thing and solve it well.

Friday, 4 May 2018

Build and deploy your chatbot #Dyn365FO

This post is a continuation from the last blog post. We will explore what it takes to build and deploy your bot.

In the Azure Portal, create a new “Web App Bot” by searching for “bot”. Select Web App Bot and follow the wizard.


Enter the required details. Make sure to change the pricing tier to the free one, if you are experimenting. It is a good idea to select your template here.


There are various templates available. Question and Answer one is a good template for fast set up of your QnA maker. If you are intending to use LUIS, select the Language understanding template. It will create LUIS project and connect it up for you.



In the App Settings you will all the application ids, secret keys etc to hook it all up.


If you used the LUIS template, you will see the LUIS application created here.



If you used the QnA template, then you will be required to enter the QnA appkey and password.

You can download the source code from the Build blade.


Tuesday, 17 April 2018

Build a Question and Answer Chatbot #Dyn365FO

I am going to do a series of posts on Chatbots. I have been working on (and off) it for about a year now. I will start slowly and build up on the concepts.

The easiest to do is probably Microsofts QnA Maker. QnA Maker can help your create an FAQ type chatbot that has language understanding. You just provide it with a link to an FAQ site or file, it will index all the content. The user then uses natural language to ask their questions.

Lets get into it.

1. Navigate to https://qnamaker.ai and sign in with your Microsoft account

Accept the terms and conditions.


2. Create a new service.

Give it a name and a source for the FAQ. This can be a URL or a flat file. Then click on Create button.


3. This will create a question and answer pair.


4. Lets test it out before we publish it.

a) Enter your text

b) Best answer it could pick up

c) Improve it by adding alternative questions. For a simple greeting intent, you could say it in many ways. Eg. Hello, Hi, Hey etc..


5. Now that you are happy and Save your work by clicking the green “Save and retain”. Then click on Publish.

This will take you to a review page. You can download your diff file to get an understanding how many new QnA pairs you have added.


6. Once you clicked publish you will get a review the keys that have been generated for you. Make sure you click on Learn how, it has many different ways of communicating to it.