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

image

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

image


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.

image

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.

image

The Excel file looks like this.

image

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.

https://youtu.be/aHI8qfofH4c?t=1032

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.

image

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.

image

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.

image


image

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

image

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

https://www.luis.ai

image

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.

image

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.

image

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.

image

3. This will create a question and answer pair.

image

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..

image

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.

image

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.

image

Friday, 13 April 2018

Add a new starting worker for workflow hierarchy approval #MSDyn365FO

This is very simple but not too obvious. There are times when you want to start the hierarchy approval with a specific worker and then have it traverse up the hierarchy.

See screenshot below screenshot of some of the options. You may want to add something different to what is already available.

image

The way it works is, it uses certain EDTs on the table.

So, all you need to do is add a field that extends one of these EDTs. Or just subscribe to the delegate to add another EDT.

Below is some code that could give inspiration.

image

image

Sunday, 1 April 2018

Add Spending/Approval limit to Purchase Order Workflow #MSDyn365FO

I feel this is very limiting when you try to use purchase order workflow via hierarchy assignment. The set up is there but you really can’t use it to the end. When you try to set up a stop condition, you can’t really use it.

Vote for the idea for Microsoft to develop this.

https://experience.dynamics.com/ideas/idea/?ideaid=6b55a93d-7235-e811-bbd3-0003ff68aa57

Below is a screenshot of how I have added it.image

To add these fields or any dynamic (calculated) field is very simple. Just a parm method to the workflow document class.

For this example, I just copied the parm method and made it point to the PurchTable.

Copy from PurchReqDocument to PurchTableDocument

Here is a class I put together to show you how I added the spending limit.

https://github.com/munib00/WorkflowPlus/blob/master/AxClass_PurchTableDocument_WP_Extension.xpp

Wednesday, 14 March 2018

Approve Workflow via email using template placeholders #Dyn365FO

Dynamics 365 for Finance and Operations has placeholders which can be inserted into the instructions. Normally you would want this to show up in the email that is sent. One of the most useful ones is the URL link to the exact record that you are approving.

In the workflow configurations use the placeholder and build up your message. Towards the end it has workflow specific ones. The URL token is %Workflow.Link to web%.

image

For the technical people the token is replaced in this class WorkflowDocumentField.

image

This is what I inserted into my email template.

<BODY>
subject: %subject%
<BR>
message: %message%
<BR>
company: %company%
<BR>
for: %for%
<BR>
</BODY>


Should look like this.

image

The final result looks like this.

image

If you debug these are the place holders that are put together.

image