Writing a Test Job in AX7, Use of Like Operator and Bulk Update of Retail Screen Layout Button Properties

The following post will touch base on-

1. How we can execute a test job in AX7 which most of us already know in the good old AX 2012 as an AOT Node.

2. Use of ‘like’ operator-  AX uses asterik ‘*’ character instead of ‘%’ which we use in SQL.

3. Changing Layouts of Retail Screens need not be tedious and time consuming by changing properties of each button manually.

A job in AX7 is simply a public class and it must have a main method that provides the runnable code. The main method was required in AX 2012 too but there was no need for the class to have access specifier as public.  Another difference is that the Jobs Node in AOT is deprecated.
So how do we write a test job in AX7? you can start by referring to this link for steps to create one
Consider that you want to bulk update the properties of buttons in the Retail Screen Layouts. The below piece of code can help to do the bulk update in a matter of few minutes,  <Update> please note this method of bulk update is ideal in some scenarios like preparation of demos  where you want to try out different values of colors for the buttons for example. However usual  approach for bulk update is DIXF https://docs.microsoft.com/nb-no/dynamics365/unified-operations/dev-itpro/lifecycle-services/ax-2012/migrate-data-dixf</Update>
Note the use of like Operator (*) in this code.

 

class TestJob

{

    public static void Main(Args args)

    {

        RetailButtonGridButtons retailButtonGridButtons;

        update_recordset retailButtonGridButtons

            setting BackColor=-65536,

                    BackColor2=-65536,

                    FontColor=0

        where retailButtonGridButtons.buttonGridId like ‘*ABC*’;

    }

}

On running the above code we get following screen on successful completion

 So with this code you dont need to go to each Button Grid in the layout and change properties manually. So you can save your time and skip having to see the following screen multiple times

 Note – This post was first published in TechTalk

-Hitesh Manglani

Failed to log on to Microsoft Dynamics

Note -If  you have a Dynamics 365 for Operations VM then follow below link

(“Provisioning the administrator” user section)

to set up and be able to login – https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-tools/access-instances

If you are using AX 2012 please continue reading-

When you have just installed AX or got a backup of the AX database from someone, you may not be able to log on to Microsoft Dynamics AX 2012. A following error message may be displayed

 

0285.Failed to logon to Microsoft Dynamics

 

The issue is that you have not been configured as a user in the AX database.

Resolution: The solution has following two steps

1.  In AX 2012 Extract your SID as follows-(Credit to Rudhra Kumar- https://community.dynamics.com/ax/f/33/t/125845)

To get SID for the current logged in domain user, please type the following in your command prompt–> C:\> whoami /user

To get SID for all domain users, please type the following in your command prompt–>wmic useraccount get name,sid whoami /user

 

2. Copy the SID into your AX database in SQL Management Studio in the table dbo.USERINFO, also change the Network Domain and NetworkAlias as per your credentials.

 

 

-Hitesh Manglani

Dynamics 365 for Operations and TLS 1.2

In my first Dynamics 365 for Operations project we had to implement an integration between the Azure hosted Dynamics 365 for Operations Retail Server and an on premise web api server (for more information on the overall Retail Topology do refer this link MPOS Technical Architecture).

The integration worked fine in our Development environment but when promoted to UAT sandbox the integration broke with the following error

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

and initially we could not understand why, after some investigation we could find out the cause being that Dynamics 365 for Operations configuration enforced a TLS 1.2 protocol while the destination server supported only TLS 1.0 and 1.1.

The following resources were very helpful to arrive at the conclusion

https://docs.microsoft.com/en-us/dynamics365/unified-operations/retail/retail-peripherals-overview

https://blogs.perficient.com/microsoft/2016/04/tsl-1-2-and-net-support/

Last but not the least, an excellent resource was the following link by John Louros.

https://www.johnlouros.com/blog/disabling-cryptographic-protocols-for-pci-compliance

In this blog, John has provided a nifty console application which was extremely helpful in understanding what was going wrong in the integration, by trying all combinations of TLS protocols between the source and destination it lets you know which protocol is supported and which one is not.

 

-Hitesh Manglani

 

 

The service is not provisioned for the same tenant

If you have downloaded an Dynamics 365 for Operations / AX7 VM for Development especially for Retail do have a look at this article

https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-tools/access-instances

Unless you do the steps mentioned in the Retail Configuration section in this link you will get errors like :

In MPOS trying to activate would give an error – The service is not provisioned for the same tenant. User is hitting a retail server that does not belong to the same tenant as the Activation account.

Also if you try to Associate User Identity with a worker in AX it will result in an error like the service is not reachable.

Note – You need to install KB3170424 if you are facing this issue in a LCS hosted VM.

 

-Hitesh Manglani

Problem uninstalling MPOS or any other application

Sometimes I have experienced an error when trying to uninstall MPOS or any other program for that matter.

MPOS uninstall

Corrupted registry keys are one of the reasons for such an error.

The following utility from Microsoft helps to cleanly uninstall MPOS  or any other program not uninstalling in such a situation.

https://support.microsoft.com/en-gb/help/17588/fix-problems-that-block-programs-from-being-installed-or-removed

In addition you may also needed to follow these steps to make sure all MPOS packages are removed (especially when multiple user profiles are setup)

  1. Run the following powershell script as Admin user. (Note that you can run the Powershell command by loading it the command prompt by executing powershell command as shown below)

Get-AppxPackage *pos* – allusers

Uninstall

2.  Note the PackageUserInformation in the above results. It will list the users for which the package has been provisioned. The package can then be removed using the following script.

Get-AppxPackage *pos*  | Remove-AppxPackage

Note – You will need to execute the above command for each user by logging in as that particular user in command prompt. For instance lets consider that there are two users admin and user1. You will need to execute the powershell twice, once as admin and once as user1, by using “Run as a different user” option by right clicking the command prompt icon

Run as a different user menu

Hope this helps

-Hitesh Manglani

[AX 2012 R3 / Dynamics 365 for Operations -Retail]: Viewing events from MPOS in Event Viewer

This post is based on a conversation in Dynamics AX Community (link attached later in the post)

 

Events from the MPOS in AX 2012 R3 can be found in Event Viewer here:

Application and Services Logs -> Microsoft -> Windows -> AppHost -> AppTracing.

activate the event log using Event Viewer.

  1. Navigate to Application and Services Logs -> Microsoft -> Windows -> AppHost.
  2. Right click AppHost and Select View -> Show Analytic and Debug Logs

Events from the MPOS in AX 7 / Dynamics 365 for Operations can be found in Event Viewer here:

Event Viewer: Applications and Services Logs->Microsoft->Dynamics->Commerce-ModernPos.- Admin, Debug, Operational (where Operational would contain errors and Debug is by default disabled but can be Enabled if needed.)

 

Please visit the source of this post at this link

for more information.

A simple customization in MPOS (Blank Operation) with Dynamics 365 for Operations

Note – This article is applicable upto Dynamics 365 for Operations- 7.1 i.e. not applicable to 7.2 and above

Hi All,

 

I recently had to add a Blank Operation to Modern POS (MPOS) to open a url from MPOS.

 

Blank Operation as you may already be aware enable you to extend Microsoft Dynamics Retail for POS by adding custom logic that can be triggered from the Retail POS Register buttons. The way to implement Blank Operations in MPOS is different from Enterprise POS as MPOS is a modern app as compared to EPOS which is a windows forms based app.

So lets explore a very simple customization i.e. we want to open a URL on triggering a button from MPOS.

1. We would need to start with AX to add a button to the layout of MPOS. If you do not want to disturb the standard layouts its better to copy one of the existing layouts and then modify it using the designer. Please note the designer only opens in Internet Explorer so it will save you time by not trying to open it in other browsers e.g Chrome

2. Next we need to add this layout to the Store where we intend to use it, in my case I have choosen Houston Store

3. We need to modify the screen layout in the worker setup.

Next run jobs 1060,1070, 1090 to push the worker,store configuration and the new screen layout respectively to Channel DB.

Lets run MPOS SDK code from Visual Studio and check if the changes are reflected.

As you can see we have a new button in MPOS which can be used to invoke custom logic. Currently on triggering the button gives us a message “The blank operation identifier is invalid”

Now make the following modifications in the code.

In POS.ViewModels->OperationsMap.ts add the following line of code to register a new handler for the custom blank operation

Operations.BlankOperationHandler.registerBlankOperationHandler(“CustomOpenURL”, new Operations.OpenURLOperationHandler());

Next we need to provide the definition for the handler, to do this headover to Pos.Core->Operations->Add a new typescript file say CustomBlankOperations.ts and paste following code.

module Commerce.Operations {

“use strict”;

export class OpenURLOperationHandler extends OperationHandlerBase {

/**

* Executes the OpenURL operation.

*

* @param { IBlankOperationOptions } options The operation options.

* @return {IAsyncResultIOperationResult>} The async result containing the operation result, if any.

*/

public execute(options: IBlankOperationOptions): IAsyncResultIOperationResult> {

// sanitize options

options = options || { operationId: undefined, operationData: undefined };

var asyncQueue: AsyncQueue = new AsyncQueue();

var asyncResult: VoidAsyncResult = new VoidAsyncResult(null);

var url = String(options);

asyncQueue.enqueue((): IAsyncResultICancelableResult> => {

Windows.System.Launcher.launchUriAsync(

new Windows.Foundation.Uri(url)

);

return asyncResult;

});

return asyncQueue.run();

}

}

}

On running the modified app you should be able to successfully run the blank operation and see the web page in this case http://www.bing.com opened in your browser.

So hopefully this exercise will whet your appetite and for a deeper dive to more MPOS customizations I would suggest the following resources to try out in AX 7-

1. http://blogs.msdn.com/b/axsa/archive/2015/02/17/extensibility-in-dynamics-ax-2012-r3-cu8-crt-retailserver-mpos-part-1.aspx

2. http://blogs.msdn.com/b/axsa/archive/2015/05/20/extensibility-in-dynamics-ax-2012-r3-cu8-crt-retailserver-mpos-part-2-new-data-entity.aspx

If you have access to Microsoft Dynamics Learning Portal do watch the following videos

Update>

https://mbspartner.microsoft.com/AX/Videos/101001

https://mbspartner.microsoft.com/AX/Videos/101002

Alternatively if have access to Partnersource use these links instead.

http://mediadl.microsoft.com/mediadl/www/d/dynamics/partners/BSAX88.mp4

http://mediadl.microsoft.com/mediadl/www/d/dynamics/partners/BSAX89.mp4

/Update>

hope this helps

-Hitesh Manglani

This post was first published at http://hiteshgoldeneye-techtalk.blogspot.sg/2015/12/a-simple-customization-in-mpos-blank.html