Module 1: MICROSOFT DYNAMICS AX 2012 R2 FOR RETAIL IN BRICK AND MORTAR STORES- DEVELOPMENT AND CUSTOMIZATION

Size: px
Start display at page:

Download "Module 1: MICROSOFT DYNAMICS AX 2012 R2 FOR RETAIL IN BRICK AND MORTAR STORES- DEVELOPMENT AND CUSTOMIZATION"

Transcription

1 Table of Contents Module 1: MICROSOFT DYNAMICS AX 2012 R2 FOR RETAIL IN BRICK AND MORTAR STORES- DEVELOPMENT AND CUSTOMIZATION Lesson 1: Course Objectives Module 2: INTRODUCTION TO POINT OF SALE (POS) OVERVIEW Lesson 1: Introduction to POS Module 3: POS EXTENSIBILITY TECHNICAL OVERVIEW Lesson 1: Extend Point of Sale Lesson 2: Retail POS Plug-ins Lesson 3: Commerce Data Exchange: Real-time Service Calls Module 4: POS FRAMEWORK Lesson 1: POS Architecture Overview Module 5: DEVELOPMENT ENVIRONMENT REQUIREMENTS Lesson 1: Development Environment Requirements Module 6: TECHNICAL BACKGROUND Lesson 1: Technical knowledge required to customize POS Module 7: LOCALIZATION INFORMATION Lesson 1: POS Localization Microsoft Official Training Materials for Microsoft Dynamics

2 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module 8: EXTENSIBILITY BEST PRACTICES Lesson 1: Solution Approach Lesson 2: Reference Module 9: LOGON EXTENSIBILITY SAMPLE AND HOW-TO Lesson 1: Logon Extensibility Module 10: POS THEMES Lesson 1: POS Skins Module 11: USER-INTERFACE EXTENSIBILITY SAMPLE AND HOW-TO Lesson 1: How to Modify a Form in Microsoft Dynamics AX 2012 R2 POS Module 12: TRIGGER EXTENSIBILITY SAMPLE AND HOW-TO Lesson 1: How to Modify the Trigger Project Module 13: SERVICES EXTENSIBILITY SAMPLE AND HOW-TO Lesson 1: How to Modify the Services Project Module 14: BLANK OPERATION EXTENSIBILITY Lesson 1: Blank Operation on the Retail POS Register Module 15: CUSTOM FIELDS ON POS LAYOUTS Lesson 1: Custom Fields on the POS Layout Microsoft Official Training Materials for Microsoft Dynamics

3 Table of Contents Module 16: REAL-TIME SERVICES EXTENSIBILITY SAMPLE AND HOW-TO Lesson 1: Extending the RetailTransactionServiceEx Class Module 17: POS PAYMENT CONNECTOR Lesson 1: Payment Connector Module 18: POS DATABASE TOOL EXTENSIBILITY FOR STORE AND OFFLINE DATABASE Lesson 1: CreateDatabase Service Module 19: EXTENSIBILITY TESTING CONSIDERATIONS Lesson 1: Testing Lesson 2: Challenges Lesson 3: Testing Considerations Module 20: EXTENSIBILITY DEPLOYMENT AND HOTFIX UPDATE CONSIDERATIONS Lesson 1: Deployment Planning Lesson 2: Deploy POS Customizations Lesson 3: Merge Any Existing Code Changes with POS and Redeploy Lesson 4: Install Updates to Non-Database Retail Components Lesson 5: Install Updates to Store Databases by Using the Retail Database Utility Lesson 6: Install Update to CDX: Real-Time Service Module 21: EXTENSIBILITY LAB MANUAL 3 Microsoft Official Training Materials for Microsoft Dynamics

4 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 4 Microsoft Official Training Materials for Microsoft Dynamics

5 MICROSOFT DYNAMICS AX 2012 R2 FOR RETAIL IN BRICK AND MORTAR STORES- DEVELOPMENT AND CUSTOMIZATION Course Objectives The main objectives of the Microsoft Dynamics for Retail in Brick and Mortar Stores course is to understand the development and customization that is explained in the following topics: Introduction to Point of Sale (POS) Overview POS extensibility technical overview POS Framework Development environment requirements Extensibility Interface Definition Triggers and Services Technical background Localization Information Extensibility Best practices Logon Extensibility Sample and How-to POS Themes User-interface Extensibility Sample and How-to Trigger Extensibility Sample and How-to Services Extensibility Sample and How-to Blank Operation Extensibility Custom Field on POS Layouts Real-time services Extensibility Sample and How-to Device Integration (Hydra, EFTPOS) POS Database Tool Extensibility For Store and Offline Database Extensibility testing considerations Extensibility deployment considerations Deployment of ongoing hotfixes for Customized POS for version(s) and code maintenance Microsoft Official Training Materials for Microsoft Dynamics 1-1

6 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Student Objectives 1. What do you expect to learn by participating in this course? 2. List three main objectives. 1-2 Microsoft Official Training Materials for Microsoft Dynamics

7 MODULE 2: INTRODUCTION TO POINT OF SALE (POS) OVERVIEW Module Overview Microsoft Dynamics AX for Retail POS is the point of sale (POS) program for Microsoft Dynamics AX. POS tasks are performed by using a POS register. The graphical user interface (UI) is easy to use and can be set up to meet the requirements of many industries, such as grocery, fashion and specialty retailers. Objectives The main objective of this module is to discuss the Microsoft Dynamics POS Overview. Microsoft Official Training Materials for Microsoft Dynamics 2-1

8 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Introduction to POS Microsoft Dynamics AX for Retail POS Microsoft Dynamics AX Retail POS is a solution that brings speed, power, flexibility, dependability, and ease of use to the point-of-sale. Retail POS has a dynamic interface that can be configured and customized for your type of business and store procedures. Additionally, Retail POS can work offline. This helps make sure that your stores remain fully operational during network interruptions. All data is automatically updated when the connection is restored. FIGURE 2.1: RETAIL SOLUTION SYSTEM OVERVIEW 2-2 Microsoft Official Training Materials for Microsoft Dynamics

9 Microsoft Dynamics Retail Components: Module 2: Introduction to Point of Sale (POS) Overview Microsoft Dynamics POS interacts with the following retail components to perform end to end operations: Commerce Data Exchange: Synch service Commerce Data Exchange: Real time service Store and offline database Microsoft Dynamics AX for Retail Synch Service: Synch service is the integrated service that periodically sends data between the head office and store database. Communications that use synch service are managed through distribution locations and Retail Scheduler in Retail Headquarters (HQ). Microsoft Dynamics AX for Retail Real time Service: Together with synch service and Retail Scheduler, real-time service completes the communications mechanism of Microsoft Dynamics AX for Retail by providing real-time, synchronous communication between POS registers and Microsoft Dynamics AX. It can be used to authenticate cashier logon credentials, send loyalty requests, and exchange up-to-the-minute physical inventory information between the head office and the stores, and more. Store Database: Each store must have its own database, and a single database is used for multiple registers. This helps make sure that the same master data is available to all POS registers in the store. Offline Database: You can also create an offline databases on POS computers. An offline database helps make sure that the store s operations can continue even if the connection to the shared database server is lost. If the connection to the shared database server is lost, the POS computers switch to offline databases. The shared database and the offline databases are kept in sync by using Microsoft Sync framework. The store and the offline database can be set up by using the create database utility. Microsoft Official Training Materials for Microsoft Dynamics 2-3

10 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Microsoft Dynamics POS Operations Microsoft Dynamics AX for Retail POS is the point of sale (POS) program for Retail. You can use Retail POS to perform the following tasks: Process sales Operate the cash drawer Scan bar codes Print customer receipts Calculate the sales total Calculate tax Calculate the change that is due back from the amount that is paid Issue product refunds Suspend transactions Process customer loyalty transactions Issue credit memos Issue gift cards Scan bar codes Receive payments Print receipts Create and track customer orders Process debit cards and credit cards Check inventory, plus many more. The following operations cannot be performed when the store database is offline: Print an X report Print a Z report Close a shift Blind-close a shift View blind-closed shifts Suspend a shift, plus more 2-4 Microsoft Official Training Materials for Microsoft Dynamics

11 Module 2: Introduction to Point of Sale (POS) Overview The following operations cannot be performed when the connectivity to HQ is not working (CDX: Real time service connection down): Inventory Lookup Gift Card Operations Loyalty Operations Customer order Operations, plus more Microsoft Official Training Materials for Microsoft Dynamics 2-5

12 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Module Review and Takeaways About Microsoft Dynamics AX 2012 POS Real time service Synch service POS Operations Store and Offline database. Test Your Knowledge Test your knowledge with the following questions. 1. What is the CDX: Synch service used for? 2. What is the CDX Real-time service used for? 3. What is the difference between the CDX synch service and the CDX Real-time service? 4. Describe any POS Operations. 5. Can an offline database be shared across multiple terminals? 6. Describe any two operations that cannot be performed when the POS store database is offline. 2-6 Microsoft Official Training Materials for Microsoft Dynamics

13 Module 2: Introduction to Point of Sale (POS) Overview Test Your Knowledge Solutions MODEL ANSWER: 1. Synch service is the integrated service that periodically sends data between the head office, stores, and individual Retail POS terminals. 2. Real-time service completes the communications mechanism of Microsoft Dynamics AX for Retail by providing real-time, synchronous communication. 3. Synch service is used for synching the data between HQ and POS. Real time service is used for providing real-time information form the HQ. 4. Receive payment operation. This operation can be used to receive payment from the customer in POS through different tender types that are configured in HQ. 5. No. Only the store database can be shared across multiple terminals. 6. Close shift and print Z-report. Microsoft Official Training Materials for Microsoft Dynamics 2-7

14 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 2-8 Microsoft Official Training Materials for Microsoft Dynamics

15 MODULE 3: POS EXTENSIBILITY TECHNICAL OVERVIEW Module Overview This module discusses the Microsoft Dynamics AX 2012 POS extensibility and its operations. Objectives The main objective of this module is to help you understand how to customize and extend the Microsoft Dynamics AX 2012 POS. After you complete this course, you will know how to customize and extend POS. Microsoft Official Training Materials for Microsoft Dynamics 3-1

16 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Extend Point of Sale Microsoft Dynamics AX for Retail POS is a fully customizable point of sale (POS) component of Microsoft Dynamics AX 2012 for Retail. You can use Retail POS to process sales, operate the cash drawer, and scan bar codes or print customer receipts, among other business tasks. Lesson Objectives How to customize or extend Microsoft Dynamics AX 2012 POS. POS Extension To customize business logic in Retail POS, you must install the Retail Software Development Kit (SDK). The SDK is included with Microsoft Dynamics AX It contains two folders: Retail POS Plug-ins POS Plug-ins Contains code that you use to extend and customize Retail POS. For more information about how to install Retail POS Plug-ins, refer to Install Retail SDK. Commerce Runtime Contains services that you use to extend and customize the online store for Microsoft Dynamics AX 2012 for Retail. The details of this are not explained in this course. This topic talks about the Retail POS Plug-ins and how to use the Plug-ins to extend or customize the business logic, user interface UI and new operations in POS. Lesson Objectives After you complete this lesson, you will know how to customize or extend the Microsoft Dynamics AX 2012 POS. About POS Plug-ins Retail POS Plug-ins contains set of services and application triggers. Most of the functionality in Retail POS is implemented by using services. For example, you use the Customer service for tracking, adding or deleting customers from the Retail POS register. 3-2 Microsoft Official Training Materials for Microsoft Dynamics

17 Module 3: POS Extensibility Technical Overview These services are a collection of the.net Framework assemblies that implement public interfaces. Refer to the POS Extensibility Interface Definition course document for more information. Retail POS loads the services at run time and invokes their functionality through these interfaces. Because Retail POS Plug-ins is included with the C# source code for these assemblies, you can customize or replace services and triggers to extend features in Retail POS, such as calculating taxes. By default, Retail POS Plug-ins is installed in the following directory: 1. C:\Users\...\Documents\Retail SDK\POS Plug-ins\ The folder contains two Visual Studio solutions one for services and the other for triggers. Triggers are used to insert custom code before or after Retail POS operations, such as issuing a gift certificate, a customer add, a clear, or a payment, and more. For example: Before you issue a gift card, if you want to do a validation such as whether the customer is eligible to issue a gift card, you can perform the validation here. The Microsoft.Dynamics.Retail.Pos.Contracts.dll assembly exposes all the public interfaces to be used for implementing extensions and customizations to the following Retail POS functionality: Operations Services Triggers Commerce Data Exchange: Real-time Service FIGURE 3.1: POS PLUG-INS Microsoft Official Training Materials for Microsoft Dynamics 3-3

18 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Operations An operation is an activity that occurs in Retail POS. Operations can be a single step or a multi-step. Refer to the POS Framework course document for more information. Services Services include one or more operations and implement a single, unique interface. You can make partial modifications to an existing service and continue to use the remaining functionality. Or, you can replace the complete service assembly with your own custom code. For more information about how to implement services, refer to How to modify a Form at Interface for Services Features in the Retail POS are services that interact with the program through interfaces. Services include one or more operations and implement a single, unique interface. Each service implement an interface. The developer can make partial or full modifications to the service s project. Microsoft Dynamics AX 2012 ships with a collection of core services that can be customized or replaced using Retail POS Plug-ins. For descriptions of all the services interfaces that are available in Retail POS, please refer Interfaces for Services" Triggers Triggers are events raised by Retail POS that enable you to insert custom code before or after operations. There are two types of triggers: Pre-triggers Post-triggers Please refer the POS Framework course document for more information. 3-4 Microsoft Official Training Materials for Microsoft Dynamics

19 Interface for Triggers Module 3: POS Extensibility Technical Overview Triggers are events that are raised by Retail POS that you can use to insert custom code before or after operations. Similar to services, triggers also implement unique interfaces. The developer can use triggers to perform pre-validations and post validations. Each trigger interface has set of methods that can be extended by the developers for customization. Pre-triggers provide an additional layer of verification and can return false if the operation should be canceled. Post-triggers let you respond to an operation after it is finished. Triggers can be extended in the same manner as services. For descriptions of all the triggers interfaces that are available in Retail POS, refer to Interfaces for triggers. Commerce Data Exchange: Real-time Service Calls Retail POS can make real-time calls to Microsoft Dynamics AX 2012 using the Commerce Data Exchange: Real-time Service. This service provides real-time, synchronous communication between Microsoft Dynamics AX 2012 and individual Retail POS terminals. Lesson Objectives This lesson helps you understand the real time service functionality of Microsoft Dynamics AX 2012 POS. Real-time Service Calls Retail POS uses real-time service calls to start Retail POS functionality, such as Issue Gift Card or Create Customer. You can create custom, real-time service functionality in Retail Headquarters and call it from Retail POS. Microsoft Official Training Materials for Microsoft Dynamics 3-5

20 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Module Review and Takeaways Tools Understand how to extend Retail POS Retail POS Plug-ins Operations Services, Triggers and Real-time services Use Visual Studio 2010 Ultimate or a more recent version to customize Microsoft Dynamics AX 2012 POS. To customize the Real-time service use in HQ, use the Morphx development suite. Test Your Knowledge Test your knowledge with the following questions. 1. What is Retail POS Plug-ins? 2. When do you use POS Plug-ins? 3. What are the two main components of Retail POS Plug-ins? 4. When should Real-time services be used? 5. What is the difference between services and triggers? 3-6 Microsoft Official Training Materials for Microsoft Dynamics

21 Test Your Knowledge Solutions MODEL ANSWER: Module 3: POS Extensibility Technical Overview 1. Retail POS Plug-ins contain sets of services and application triggers to extend POS 2. To extend or customize POS 3. Services and Triggers 4. Any real-time, synchronous communication between Microsoft Dynamics AX 2012 and individual Retail POS terminals like Gift card, loyalty 5. Services contains the core business logic whereas triggers are events raised by Retail POS that enable you to insert custom code before or after operations. Microsoft Official Training Materials for Microsoft Dynamics 3-7

22 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 3-8 Microsoft Official Training Materials for Microsoft Dynamics

23 MODULE 4: POS FRAMEWORK Module Overview This module explains the POS technical architecture. This module also provides information about the different components in the POS framework Objectives The main objective of this module is to help understand the POS technical framework, its components and other retail components it uses. Microsoft Official Training Materials for Microsoft Dynamics 4-1

24 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization POS Architecture Overview This course provides information about the different POS architecture components that include the following: POS Core CDX: Real time service and Synch service POS Database POS Architecture The POS Architecture consists of the POS Core components. FIGURE 4.1: POS ARCHITECTURE CORE COMPONENTS 4-2 Microsoft Official Training Materials for Microsoft Dynamics

25 POS Core Module 4: POS Framework The POS core is the focal point of POS that interacts between the POS user interface (UI), and the POS data layer, services and triggers. The key components of the POS core include the following: Operations Transaction SystemFramework SystemeSettings DataAccess (Data Layer) Contracts The components in the POS core are not extensible. FIGURE 4.2: POS COMPONENTS Microsoft Official Training Materials for Microsoft Dynamics 4-3

26 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Operations An operation is an activity that occurs in Retail POS. Operations can be a single step, or a multi-step. For example, Add Item adds a sales line to the current transaction. The Customer add operation presents a form for a cashier to enter customer information. After data is entered and the form is closed, the customer information is sent to Retail Headquarters. Microsoft Dynamics AX 2012 includes a collection of core operations that cannot be modified. However, you can create new functionality by using the BlankOperations. You can use Blank Operations to extend Microsoft Dynamics AX for Retail POS by adding custom logic to the Retail POS register buttons. In the Retail POS register, you can add the blank operation button to the POS layout and link it with your custom operations. Transaction The transaction dll contains the core transaction classes and Interfaces that are used in standard and extended components. Most POS operations will have the POS transaction passed as parameters that are during the operation. System Framework: This dll contains the transaction service. This service is a direct start to Headquarters (HQ). System Settings: This dll contains all the settings that are related to connection details, operator details, terminal details, store details, transaction service details, hardware profile, functionality profile and other Application details that can be used while extending POS. Data Access: This dll acts as a data layer between the application and the POS database. It provides a set of interfaces and, or classes that are used in standard operations, services and triggers. Contracts The contracts dll contains interfaces that are used across multiple core and extended components of Point of Sale. When POS Plugins are installed, this dll is included as part of plugin code. When you extend a service and, or triggers, add this dll to the project. Also, dll should be deployed to the POS folder, after you extend. 4-4 Microsoft Official Training Materials for Microsoft Dynamics

27 POS Extensibility Module 4: POS Framework POS Extensibility points give the user the option to extend the POS for custom requirements. The key components include the following: Services Forms Although third-party components from the DevExpress libraries were used to build the POS application, you do not have to be familiar with how to set up a development environment by using the DevExpress libraries. All Windows forms in POS are developed by using the "DXExperience Winforms" product that is created by DevExpress. However, you must have a DevExpress license to modify the design-time visual changes to existing forms. Although you are not required to have DevExpress tools to create new POS forms, it is recommended that you use them to have a consistent appearance with the rest of the product. Microsoft Dynamics AX 2012 R2 POS introduces a new way to customize forms by using the Interaction service. Multiple developers can customize one or more forms in one service. If there are multiple customizations, the Interaction service loads only the first customization it finds for a form. The following list of forms uses this new pattern and their implementations are included in the InteractionDefaults service. ExtendedLogOnForm ExtendedLogOnScanForm frmbarcodeselect frmdimensions frminput frmpaycash frmpaycurrency frmpaycustomeraccount frmreturntransaction LogbookForm LogOnForm ManagerAccessForm RegisterTimeForm ViewTimeClockEntriesForm ProductDetailsForm ProductInformationForm Microsoft Official Training Materials for Microsoft Dynamics 4-5

28 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Skins: By using the DevExpress SkinEditor program, you can change the appearance of Microsoft Dynamics AX for Retail POS registers by creating new Retail POS skins. To create new Retail POS skins, you must obtain a license from DevExpress. Retail POS uses DXExperience Winforms that is created by DevExpress. You can develop your own forms without having to use DevExpress. However, it is recommended that you use these to maintain a consistent appearance. CDX: Real-time service Retail POS can make real-time calls to Microsoft Dynamics AX 2012 by using the Commerce Data Exchange: Real-time Service. This service provides real-time, synchronous communication between Microsoft Dynamics AX 2012 and individual Retail POS registers. Retail POS uses real-time service calls to provide some Retail POS functionality, such as Issue Gift Card or Create Customer. You can create custom, real-time service functionality in Retail Headquarters and call it from Retail POS. In Retail R2 the Real-time Service changed from a Windows Service to an IIS Web Service. It acts as a traffic handler between the POS and Headquarters to share real-time information. All actual logic is written in X++ code that is hosted in the Application Object Server (AOS) and accessed through the.net Business Connector. This change in architecture means that the installation and configuration includes many changes. Refer to the installation guide to set up the new real time service. 4-6 Microsoft Official Training Materials for Microsoft Dynamics

29 Module 4: POS Framework FIGURE 4.3: REAL-TIME SERVICE CDX: Synch Service (Retail Store Connect) Commerce Data Exchange: Synch Service is a service that shares data among retail components. These components include the head office, stores, and individual point of sale (POS) terminals. When you install Synch Service, the Retail Salt Utility and Retail Scheduler are also installed. The Retail Salt Utility provides additional encryption for the passwords and credentials that are associated with the Retail system. Retail Scheduler is used to manage the distribution of data between the head office and the stores Microsoft Official Training Materials for Microsoft Dynamics 4-7

30 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization FIGURE 4.4: CDX SYNCH SERVICE POS Database This lesson explains about the POS store database and offline database. Lesson Objectives Store Database Offline Database Retail Offline Synch Service Store Database Store database is a central database that is inside a store. Typically, a store database is hosted on a shared server that is connected to all the POS terminals in the store. Multiple POS computers in a store can connect to the same store database. Store database data is synched with HQ by using the Synch service. 4-8 Microsoft Official Training Materials for Microsoft Dynamics

31 Offline Database: Module 4: POS Framework Together with the store database, you can also create the offline database on the POS terminal. This helps make sure that the store operation can continue even if the connection to the shared database (store database) is lost. Retail Offline Synch Service: The shared database and the offline databases are kept in sync by Microsoft Dynamics AX for Retail Offline Sync Service. This Windows service will run in the POS computer and synch the data between the shared database and the offline database. Microsoft Official Training Materials for Microsoft Dynamics 4-9

32 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Module Review and Takeaways POS Architecture POS Core CDX : Real time service and Synch service POS Database Test Your Knowledge Test your knowledge with the following questions. 1. What are the main components of the POS architecture? 2. What is the POS Core? 3. How is the Transaction library used? 4. How is the CDX Synch service used? 5. Which service synchs the data between the store database and the offline database? 4-10 Microsoft Official Training Materials for Microsoft Dynamics

33 Module 4: POS Framework Test Your Knowledge Solutions MODEL ANSWER: POS Core, CDX Real-time service, CDX Synch service and store database The POS core is the focal point of the POS that interacts between the POS UI and the POS data layer. The dll transaction contains the core transaction classes and the Interfaces that are used in standard and extended components. Most POS operations will have the POS transaction passed as parameters, which are used during the operation. Retail offline synch service. Microsoft Official Training Materials for Microsoft Dynamics 4-11

34 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 4-12 Microsoft Official Training Materials for Microsoft Dynamics

35 MODULE 5: DEVELOPMENT ENVIRONMENT REQUIREMENTS Module Overview This module will explain the development environment requirements. Objectives Explain the development environment requirements. Microsoft Official Training Materials for Microsoft Dynamics 5-1

36 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Development Environment Requirements System Requirements The development environment that is shown the following table assumes that all the components are installed in single box. If you are installing each component on different boxes, then refer to the AX2012 System Requirements document for detailed information. Components Operating System Requirements Windows Server 2012 Standard Edition or Datacenter Edition Windows Server 2008 R2 Standard Edition, Enterprise Edition, Web Edition, or Datacenter Edition Windows Server 2008 Standard Edition, Enterprise Edition, Web Edition, or Datacenter Edition, with Service Pack 2 (Only 64-bit versions of Windows Server 2008 are supported) Processor RAM Hard disk space Intel Pentium/Celeron family or a compatible Pentium III Xeon or larger processor. We recommend a processor speed of 1.1 GHz or larger. Important: Microsoft Dynamics AX is not supported on Itanium 64-bit processors. We recommend 4 GB or more of RAM for server computers. Minimum 80 GB 5-2 Microsoft Official Training Materials for Microsoft Dynamics

37 Module 5: Development Environment Requirements Software Requirements Components Requirements Notes Application Object Server (AOS) NET Framework 4.0, with the hotfix from Knowledge Base article , ( 0372). SQL Server 2008 Native Client Install SQL Server Native Client on the AOS server if the AOS server is separate from the database server. You must install the SQL Server 2008 version of the Native Client, even if you are using SQL Server AX Client.NET Framework 4.0 Debugger No additional software requirements Visual Studio and Tools Windows PowerShell 2.0 Visual Studio 2010, Professional Edition, Premium Edition, Ultimate Edition, or Team Edition, with Service Pack 1 Visual Studio 2012 can be installed side by side with Visual Studio However, Visual Studio 2012 is not supported for Microsoft Dynamics AX development..net Business Connector No additional software requirements Microsoft Official Training Materials for Microsoft Dynamics 5-3

38 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Components Requirements Notes Database The Retail module in Microsoft Dynamics AX, Retail POS, Commerce Data Exchange: Synch Service and Real-time service, Retail Store Database Utility and Retail SDK Microsoft SQL Server 2012, Standard Edition, Enterprise Edition, or Business Intelligence Edition. Service Pack 1 ( nload/details.aspx?id=35575) is supported. However, it is not required. or SQL Server 2008 R2, Standard Edition, Enterprise Edition, or Datacenter Edition. Service Pack 1 ( /en/details.aspx?id=26727) and Service Pack 2 ( nload/details.aspx?id=30437) are supported. Service Pack 1 is required if you are installing Reporting Services extensions. or SQL Server 2008, Standard Edition or Enterprise Edition, with Service Pack 1. Service Pack 3 is supported. However, it is not required. Application Object Server (AOS), OS and other components are mentioned earlier in this document. By default, SQL Server 2012 is supported with Microsoft Dynamics AX 2012 R2. To use SQL Server 2012 with an earlier version of Microsoft Dynamics AX 2012, you must install Microsoft Dynamics AX hotfix ( om/knowledgebase/kbdi splay.aspx?scid=kb;enus; ). Only 64-bit versions of SQL Server are supported. For the minimum hardware requirements for SQL Server, see /sql/default.mspx. In a production environment, we recommend that you install the latest cumulative update for the version of SQL Server that you are using. 5-4 Microsoft Official Training Materials for Microsoft Dynamics

39 MODULE 6: TECHNICAL BACKGROUND Module Overview This module provides information about the knowledge required to customize POS Objectives Understand the knowledge required to customize the POS Microsoft Official Training Materials for Microsoft Dynamics 6-1

40 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Technical knowledge required to customize POS In this lesson we will understand the technical knowledge required for the developer to customize POS. Microsoft.Net framework The developer should have basic knowledge on.net framework and advanced knowledge on C#. Retail POS is developed using C#, and thus knowledge in c# is mandatory. POS Functionality The developer should have a basic understanding of POS processes and functionality to extend or customize POS. Please refer POS functional training document (AX2012 ENUS_RTL) for more information. SQL Server 2008 or higher version Basic knowledge on SQL Server is required to customize POS because we will be creating or modifying the tables, stored procedures for POS Retail HQ Setup and Configuration It is preferable to have knowledge on HQ Retail setup (Distribution schedule) and configuration like CDX sync and real time services to quickly diagnose the problem and issues. Knowledge on X++ Basic knowledge on x++ is required to customize or extend CDX Real-time service. 6-2 Microsoft Official Training Materials for Microsoft Dynamics

41 MODULE 7: LOCALIZATION INFORMATION Module Overview This module provides information about how to localize Point of Sale (POS) by changing the POS labels and strings. Objectives Explain the requirements that are used to change POS labels and strings. Microsoft Official Training Materials for Microsoft Dynamics 7-1

42 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization POS Localization Localization is the process of adapting software to meet country-specific laws or regulations. Microsoft localizes Microsoft Dynamics AX to include features and functionality designed to address specific tax, accounting or financial reporting requirements for various countries. Languages Translation is the process of adapting software or documentation to meet language requirements for a particular country. For any given language, Microsoft may translate some, all or none of the user interface (UI) and documentation for Microsoft Dynamics AX. To set up POS in specific language, go the respective Retail Channel and change the retail channel language. We can change the language in AX Retail by navigating to Retail->Common->Retail channels->retail stores->language FIGURE 7.1: SET UP POS IN SPECIFIC LANGUAGE A very common requirement to localize the POS in Dynamics AX for Retail is to change the wording of the strings and labels in the product. In this lesson we will learn how to do that. 7-2 Microsoft Official Training Materials for Microsoft Dynamics

43 Module 7: Localization Information POS Labels and Strings Nearly every string that is used in the product resides in the POSResources.resources.dll file in the POS folder. The English (en-us) version of this file is in the root folder, and then we have one for all of the localized translations: fi\posresources.resources.dll, fr\posresources.resources.dll, etc. When the POS application needs a string, it checks in the following places in the order listed: The dbo.retaillanguagetext table in the POS database The POSResources.resources.dll file for the language currently being used When a string is found, it gets cached for the remainder of the POS instance lifetime. As a developer, this means that you cannot manipulate the strings at runtime any changes that are made to the table do not get reflected until the next time the app is started. Change/Add POS Labels and strings To change the text of an existing label or string, we need to populate three columns in the RETAILLANGAUGETEXT table: LANGUAGEID, TEXTID, and TEXT (the remaining columns are deprecated and are no longer used in the product). LANGUAGEID and TEXT are the language Id in AX and the actual text to be displayed in POS. But to get the TEXTID we can follow the below step: Modify the POS shortcut and append a -tr as a command-line argument, POS will run in a special developer mode where each string and label is prepended with the TEXTID. This will allow you to find exactly which strings and labels match up with which ID. Microsoft Official Training Materials for Microsoft Dynamics 7-3

44 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization FIGURE 7.2: RETAIL POS PROPERTIES 7-4 Microsoft Official Training Materials for Microsoft Dynamics

45 Module 7: Localization Information FIGURE 7.3: OPERATOR ID Find the ID of the string that you want to change and then add the new text to the RetailLanguageText table with ID you of the string you want to change. Since there is no form for adding strings to the RetailLanguageText table, we will populate the values directly in the AOT. Open a new developer workspace and navigate to Data Dictionary > Tables > RetailLanguageText. Right-click and select Open. Create a new records by populating the languageid, Text and textid fields: Microsoft Official Training Materials for Microsoft Dynamics 7-5

46 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization FIGURE 7.4: EMPLOYEE ID Also use the RETAILLANGUAGETEXT table for any strings that you create from scratch. The Blank Operation sample plug-in uses as a starting number; that number through are currently un-used. We can use the number between these series for our custom strings. Please make sure that TextID is not conflicting with strings from other developers or possibly by future versions of the product. Once you ve added your strings to the table, you can use this method to grab strings from the table. mystring = ApplicationLocalizer.Language.Translate(28); 7-6 Microsoft Official Training Materials for Microsoft Dynamics

47 Module 7: Localization Information Module Review Module Review and Takeaways Understand how to change POS Strings and labels Test Your Knowledge Test your knowledge with the following questions. 1. What is the command parameter used to launch POS in special mode which displays the label ids? 2. In which table the POS custom strings and labels are stored? 3. Which library stores all the POS labels and string resources? Microsoft Official Training Materials for Microsoft Dynamics 7-7

48 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Test Your Knowledge Solutions MODEL ANSWER: 1. -tr 2. RETAILLANGUAGETEXT table 3. POSResources.resources.dll 7-8 Microsoft Official Training Materials for Microsoft Dynamics

49 MODULE 8: EXTENSIBILITY BEST PRACTICES Module Overview AX Retail POS (Point of Sales) is a.net solution which is available as part of AX Retail installation. The SDK will be available for the implementation team to customize further as per the specific customer s requirement. With the SDK we can customize the POS services and Triggers only. This document provides general guidelines on how to customize the Retail solution and overall solution approach for the POS Retail part. As this is on.net,.net specific coding guidelines will be applicable by default. Objectives Provide best practices and guidelines/standards for Retail POS customization. Microsoft Official Training Materials for Microsoft Dynamics 8-1

50 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Solution Approach There are two primary approaches for POS customization. These are: 1. Greenfield Development 2. Brownfield Development Greenfield Development The Greenfield approach for adding customizations on POS is to implement the customization in default interfaces provided by the plugins. Then Replace the OOB DLL provided by the Retail POS installation with the custom DLL. For example, in order to customize the Sales Order service, load the services solution form the Retail POS SDK(By default the SDK path will be C:\Users\...\Documents\Retail SDK\POS Plug-ins\) folder and extend it by adding the new classes and methods within the same SalesOrder project. Brownfield Development In brownfield development style, partial classes are used to keep customized code separate from the OOB plugins code. The advantages of using partial classes is that Customized code resides in a separate file rather than existing plugin code file which help in code merging during the hotfix deployment and we will have the clear separation of code between the customization and OOB Retail SDK. In future, if there are any upgrades or hot fixes release, developers can make those changes to OOB Plugin code by comparing it with the new updates in code, while customized code can be demarked clearly During operations lifecycle of the system, you can more easily find if the issue belongs to OOB Plugin code or it is customized code In all Retail implementation of AX, each customer will have a specific requirement for authorizing credit card payments. To do that, developer will have to modify the EFT class provided in the EFT Project. To incorporate this change, follow the below steps: 8-2 Microsoft Official Training Materials for Microsoft Dynamics

51 Module 8: Extensibility Best Practices Create a new C# file Taking the Credit card Payment Processing scenario, create a new file called _EFT.cs in the EFT project, as shown in the figure below. Modify the class declaration and namespace In the new class file created, Rename the class declaration to partial class; in the current scenario, it will be public partial class EFT : IEFT Rename the namespace to match the OOB class, which in the current scenario, will be namespace EFT Copy namespaces from OOB class, to the new class file Implement new methods or comment the existing methods in the OOB class and implement it as required in the new partial class. In the OOB file class, If the class is not partial class, rename the class declaration to partial; in the current scenario, it will be public partial class EFT: IEFT Source Code Control Source code control gives you the benefits of versioning, tracking and reverting back to earlier versions. If you are part of a team customizing POS, automated source code control provides a significant advantage. When many people work together to create, support, and update source code files for POS, the coordination of files and updates is a complex process. Team Foundation Server (TFS) provides stable, easy-to-use source code management to keep the team's developers in sync with each other's changes. Solution Configuration When setting the solution in TFS, the delivery team must configure the complete Services and Triggers solution in TFS. While configuring the Services or Triggers solution, proper version of the AX Retail POS version must be chosen (AX 2012 R2) From the Services or Triggers solution, the project specific solution must be configured as a branch from the main application. By doing this, we are keeping the original source code as is in the main solution and keep only the project specific code in the branch Microsoft Official Training Materials for Microsoft Dynamics 8-3

52 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization The projects which we are not used for customization from the Retail SDK can be removed from the TFS branch. In this way, the delivery team will be focused only on the items they will be modifying and delivering to the customer. The solution available in the branch should comply with the coding standards of.net like FxCop, StyleCop, VS Code analysis and Code metric standards. For detailed information on these standards please refer the link in the reference section. TFS for Version control.net solution Daily builds Use Release version of the dlls for deploying to testing, Staging and Production environments Unit Testing It is usually conducted by the development team. This testing is to verify and validate that the individual units of source code are fit for use. Considerations: The ability of the system to properly process erroneous transactions systems or components pass data and control correctly to one another Using Test Driven Development (TDD) developer can write unit test cases for solution before actually writing that code. By writing a test and then writing the code to make that test pass developers have a much better idea of what the goal and purpose of the code is. Also, a TDD comprehensive suite of unit tests can be run at any time to provide feedback that the software is still working. It improves the quality of code and ensures total code coverage of custom code. The developer can use Visual T#, NUnit, MS Test, xunit or any other viable unit test framework for TDD driven unit testing. For detailed information on the unit testing please refer the link in the reference section 8-4 Microsoft Official Training Materials for Microsoft Dynamics

53 Module 8: Extensibility Best Practices Reference Partial Classes and Methods (C# Programming Guide) - AX for Retail: A Better Sample for EFT plug-in (Credit Card processing) C# coding guidelines Guidelines for Test-Driven Development Test Driven Development Visual Studio 2010: Test Driven Development FxCop Code analysis StyleCop Code Metrics: Microsoft Official Training Materials for Microsoft Dynamics 8-5

54 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Best Practice: 1. Follow C# coding guidelines 2. Follow FxCop and StyleCop standards 3. Enable static code analysis in VS 4. Follow the below code metrics: Maintainability Index per method > 20 Cyclomatic Complexity per method <= 20 Class Coupling per class or type <= 20 Depth Of Inheritance per class or type <= 6 Lines of code per method <= 40 Test Your Knowledge Test your knowledge with the following questions. 1. What is Greenfield development 2. What is Brownfield development 8-6 Microsoft Official Training Materials for Microsoft Dynamics

55 Test Your Knowledge Solutions MODEL ANSWER: Module 8: Extensibility Best Practices 1. In Greenfield approach all the customization is done in new classes or projects and added as reference 2. In Brownfield approach customizations are done in partial classes. Microsoft Official Training Materials for Microsoft Dynamics 8-7

56 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 8-8 Microsoft Official Training Materials for Microsoft Dynamics

57 MODULE 9: LOGON EXTENSIBILITY SAMPLE AND HOW-TO Module Overview In this module we will learn how to extend POS Logon functionality and support for using any external device for logon like Biometric devices. Objectives Understand how to extend POS Logon functionality. Microsoft Official Training Materials for Microsoft Dynamics 9-1

58 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Logon Extensibility This lesson provides brief information about the POS Logon extensibility feature using some external devices or any other mediums. Extending Logon by using Biometric devices: Dynamics AX Retail 2012 R2 POS allows ISVs to use biometric device for logon. Following interface must be implemented by POS plugin: FIGURE 9.1: BIOMETRIC DEVICE FOR LOGON INTERFACE Following the typical sequence for POS logon follow and call into the biometric plugin 9-2 Microsoft Official Training Materials for Microsoft Dynamics

59 Module 9: Logon Extensibility Sample and How-To FIGURE 9.2: SEQUENCE FOR BIOMETRIC PLUGIN Steps to implement biometric logon: 1. Implement following interface in a new POS logon plugin assembly. Microsoft.Dynamics.Retail.Pos.Contracts.Services.IBiometricDevice 2. Copy the POS plugin and related assemblies to the \Extensibility directory under your POS directory. 3. Launch POS 4. Go to Extended Log on operation and click assign on any staff to enroll for biometric logon. The sample provides information on how to extend the logon functionality in POS to use Biometric devices. Microsoft Official Training Materials for Microsoft Dynamics 9-3

60 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Biometric Plugin The below code provides the abstract for implementing the Biometric plugin. We can extend this code to implement biometric login in POS. public sealed class BiometricPlugin : IBiometricDevice { public event BiometricDeviceDataEventHandler DataReceived; public event BiometricDeviceStatusEventHandler StatusUpdate; public void Load() { // Init the biometric device } public void Unload() { // Cleanup } public string DeviceName { get { return string.empty; } } public string DeviceDescription { get { return string.empty; } } public bool IsActive { get { return true; } } public void BeginEnrollCapture() { // Create worker thread for enroll capture and return } public void BeginVerifyCapture() { // Create worker thread for verify capture and return } public void EndCapture() { // close the thread. } 9-4 Microsoft Official Training Materials for Microsoft Dynamics

61 Module 9: Logon Extensibility Sample and How-To public string Identify(IExtendedLogOnInfo capturedata, ICollection<byte[]> candidates) { string logonkey = null; // Identify the give capture data from given cadidates and return hash (e.g. MD5 HASH) of found cadidate. } } return logonkey; Microsoft Official Training Materials for Microsoft Dynamics 9-5

62 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Module Review and Takeaways Understand how to extend Log on functionality in POS Test Your Knowledge Test your knowledge with the following questions. 1. What Services project used for Logon functionality extension? 9-6 Microsoft Official Training Materials for Microsoft Dynamics

63 Test Your Knowledge Solutions Module 9: Logon Extensibility Sample and How-To MODEL ANSWER: 1. LogOn Microsoft Official Training Materials for Microsoft Dynamics 9-7

64 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 9-8 Microsoft Official Training Materials for Microsoft Dynamics

65 MODULE 10: POS THEMES Module Overview In this module you will understand how to change the look and feel of Microsoft Dynamics AX for Retail POS registers by creating new Retail POS skins. To create or modify existing Retail POS skins, you must obtain a license from DevExpress. Retail POS uses DXExperience Winforms created by DevExpress. You can develop your own forms without using DevExpress, but it is recommended you use these to maintain a consistent look and feel. Objectives Understand how to create or modify existing Retail POS Skins Microsoft Official Training Materials for Microsoft Dynamics 10-1

66 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization POS Skins Creating a new skin Go to the SkinEditor tool, which is typically found at <root>\program Files (x86)\devexpress \Components\Tools\Windows Forms (where is the version number of the product). Double-click the SkinEditor icon to launch the tool. Click File->New to open the New Project window. FIGURE 10.1: NEW PROJECT WINDOW Set the Project Name to MyFirstCustomSkin. Change the Template Skin: field from DevExpressStyle to Office 2010 Blue using the dropdown arrow. Set the Skin Name: to MyFirstCustomSkin and click the OK button. Your new skin project is now loaded within the SkinEditor tool, which contains a list of UI elements called Products. For the remainder of this topic, Products will be referred to as controls Microsoft Official Training Materials for Microsoft Dynamics

67 Module 10: POS Themes FIGURE 10.2: CUSTOM SKIN WINDOW Setting color properties on your new skin: Select the common property from the SkinEditor Tool FIGURE 10.3: SKIN EDITOR TOOL Microsoft Official Training Materials for Microsoft Dynamics 10-3

68 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Set the Common > Control color property to Blue. Set the Common > ControlText color property to White. Click File->Save. You must now convert your project into an assembly that will be used by Retail POS. Click File->Create Assembly. You should see a confirmation dialog similar to the following: FIGURE 10.4: ASSEMBLY GENERATED INFORMATION WINDOW The newly generated skin assemblies are placed in the <root>:\users\<username>\documents\my DXSkins\ directory. There will be a folder beneath that directory with the same name as your skin, in this case MyFirstCustomSkin. Inside that folder, you will find a MyFirstCustomSkin.dll. Launching Retail POS with your new skin: In order for Retail POS to load your new skin, you must place the skin assembly in the Retail POS runtime folder. Copy the MyFirstCustomSkin.dll to the Skins folder underneath the Retail POS runtime directory. You also need to make Retail POS aware of your new skin. Using Commerce Data Exchange: Synch Service Open Microsoft Dynamics AX for Retail Headquarters and go to Retail->Setup->POS->Profiles->Visual Profiles. Right-click the Theme dropdown and click View Details. Click the New button and set the POS skin name field to MyFirstCustomSkin. Close the POS skins form and with the POS visual profiles form still open, set the Theme dropdown to MyFirstCustomSkin. Close the form Microsoft Official Training Materials for Microsoft Dynamics

69 Module 10: POS Themes Go to Retail->Periodic->Data Distribution->Distribution Schedule. Select the N-1090 job and then click the Run directly button. This will synch the new skin to Retail POS. You can run the following query against the AXRetailPOS database to make sure this procedure worked: SELECT POSSKINNAME, * from RetailVisualProfile Launch Retail POS and your new skin s visualization effects should display similar to the following image. FIGURE 10.5: SKIN VISULATION EFFECTS DISPLAY Microsoft Official Training Materials for Microsoft Dynamics 10-5

70 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Module Review Tools DevExpress SkinEditor Tool. Test Your Knowledge Test your knowledge with the following questions. 1. How will you update the new skin created using the tool in POS 10-6 Microsoft Official Training Materials for Microsoft Dynamics

71 Test Your Knowledge Solutions Module 10: POS Themes Module Review and Takeaways 1. How will you update the new skin created using the tool in POS MODEL ANSWER: In order for Retail POS to load your new skin, you must place the skin assembly in the Retail POS runtime folder. Copy the MyFirstCustomSkin.dll to the Skins folder underneath the Retail POS runtime directory. Also update the new skin name in Retail->Setup- >POS->Profiles->Visual Profiles and run the N-1090 scheduler job. Microsoft Official Training Materials for Microsoft Dynamics 10-7

72 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 10-8 Microsoft Official Training Materials for Microsoft Dynamics

73 MODULE 11: USER-INTERFACE EXTENSIBILITY SAMPLE AND HOW-TO Module Overview Microsoft Dynamics AX for Retail POS introduces a new way to customize forms by using the Interaction service. Multiple developers can use this service to customize one or more forms in one service. If there are multiple customizations, the Interaction service loads only the first customization it finds for a form. This module also explains how to customize forms that are not part of the Interaction services. Microsoft Official Training Materials for Microsoft Dynamics 11-1

74 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization How to Modify a Form in Microsoft Dynamics AX 2012 R2 POS This lesson explains how to modify the Microsoft Dynamics AX 2012 R2 POS forms in Interaction service and other services forms. Lesson Objectives Explain how to customize a form by using the InteractionDefault service. Explain how to customize forms in POS Plugins without using the InteractionDefault service. Customizing Forms by Using InteractionDefault Service The following list of forms use this new pattern and their implementations are included in the InteractionDefaults service. ExtendedLogOnForm ExtendedLogOnScanForm frmbarcodeselect frmdimensions frminput frmpaycash frmpaycurrency frmpaycustomeraccount frmreturntransaction LogbookForm LogOnForm ManagerAccessForm RegisterTimeForm ViewTimeClockEntriesForm ProductDetailsForm ProductInformationForm 11-2 Microsoft Official Training Materials for Microsoft Dynamics

75 Module 11: User-Interface Extensibility Sample and How-To To customize an interaction form, follow these steps. 1. In the folder where you installed the Retail POS SDK, open the Microsoft Dynamics AX for Retail POS Plug-ins folder. 2. Open the Services folder and double-click the Services Visual Studio solution file. In this step, you override the LogOnForm form. This form has a dependency on the ManagerAccessForm. 3. To change the background color, right-click the LoOnForm.cs from InteractionDefuslt project and select View Code. 4. Add the following code to the OnLoad() method for the first line of the method to change the back ground color to dark red. Sample code to change the form background color ((Form)this.BackColor = Color.DarkRed; 5. Compile the InteractionDefaults project. 6. Copy the new assembly to the Pos\Services\InteractionDefaults\Extension folder and start Retail POS. The LogOnForm should resemble the following: FIGURE 11.1: OPERATOR ID WINDOW Microsoft Official Training Materials for Microsoft Dynamics 11-3

76 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization How to Modify a Form in the Microsoft Dynamics Ax 2012 R2 POS Item Search Form This topic explains how to add a new column to the existing Item search form and view that form in the POS user interface (UI). For example, you will add the column SerachName of the Item in the Item search form. You will fetch this column value from the ECORESPRODUCT table. To customize the ItemSearch form, follow these steps. By default, in the folder where you installed the Retail POS Software Development Kit (SDK), it will be located at C:\Users\...\Documents\Retail SDK\POS Plug-ins. 1. Open the Microsoft Dynamics AX for Retail POS Plug-ins folder. For more information about how to install the Retail SDK, refer to the installation guide. 2. Open the Services folder and double-click the Visual Studio solution file, services.sln. 3. Open the Services folder and double-click the Services Visual Studio solution file. 4. Click the Dialog project and expand the WinFormsTouch Folder. Click frmitemsearch.cs and select view code. To modify the forms, you must have a DevExpres license. 5. Add the following code in the variable declaration section of the frmitemsearch class to declare the new column. private DevExpress.XtraGrid.Columns.GridColumn colsearchstring; 6. Initialize the column in InitializeComponent() method. this.colsearchstring = new evexpress.xtragrid.columns.gridcolumn(); 7. You must add the column in the gridview to appear in the form. For this include the new column in the range and set the column properties in InitializeComponent() method. this.grdview.columns.addrange(new DevExpress.XtraGrid.Columns.GridColumn[] { this.colitemname, this.colitemid, this.colsearchstring, this.colitemprice, this.colitemunitofmeasure, this.colitemtaxrate, this.colitemownthirdproduc, this.colitemroundtrunc}); 11-4 Microsoft Official Training Materials for Microsoft Dynamics

77 Module 11: User-Interface Extensibility Sample and How-To // // colsearchstring // this.colsearchstring.caption = "Search name"; this.colsearchstring.fieldname = "SEARCHNAME"; this.colsearchstring.name = "colsearchstring"; this.colsearchstring.optionscolumn.allowsort = DevExpress.Utils.DefaultBoolean.False; this.colsearchstring.sortmode = DevExpress.XtraGrid.ColumnSortMode.Custom; this.colsearchstring.visible = true; this.colsearchstring.visibleindex = 0; this.colsearchstring.width = 161; 8. Now, modify the Item Search query to include the new column in the search criteria for filtering and displaying in the GetItemList() method. string query = string.format("select ITEMID, ITEMNAME, '' AS ITEMPRICE,I.SEARCHNAME, I.UNITOFMEASURE, I.INVENTPRODUCTTYPE_BR " + "FROM ( " + " SELECT IT.INVENTPRODUCTTYPE_BR, IT.ITEMID, COALESCE(TR.NAME, IT.ITEMNAME, IT.ITEMID) AS ITEMNAME, IT.DATAAREAID, ISNULL(IM.UNITID, '') AS UNITOFMEASURE, ROW_NUMBER() " + " OVER (ORDER BY IT.{0} {1}) AS ROW " + " FROM ASSORTEDINVENTITEMS IT " + " JOIN INVENTTABLEMODULE IM ON IT.ITEMID = IM.ITEMID AND IM.MODULETYPE = 2 " + " JOIN ECORESPRODUCT AS PR ON PR.RECID = IT.PRODUCT " + " LEFT JOIN ECORESPRODUCTTRANSLATION AS TR ON PR.RECID = TR.PRODUCT AND TR.LANGUAGEID " + " WHERE IT.STORERECID {2}) I " + "WHERE I.DATAAREAID=@DATAAREAID AND I.ROW AND I.ROW ", sortby, asc, search); 9. Build the project in release mode and replace the Dialog.dll in the Retail POS\Services\Extension folder. This path is applicable only for Microsoft Dynamics AX 2012 R2. For later versions use POS\Extensions. 10. Start the POS and then click the Product search button that is added in the POS layout. The Item search form should resemble the following. Microsoft Official Training Materials for Microsoft Dynamics 11-5

78 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization FIGURE 11.2: PRODUCT SEARCH WINDOW 11-6 Microsoft Official Training Materials for Microsoft Dynamics

79 MODULE 12: TRIGGER EXTENSIBILITY SAMPLE AND HOW-TO Module Overview Triggers are used to capture events that start before and after Microsoft Dynamics AX for Retail POS operations. You can insert custom logic before the operation runs or after it is completed. The Retail POS IOperationTriggers interface introduces new generic triggers called the PreProcessOperation and PostProcessOperation. Objectives Explain how to extend triggers in Microsoft Dynamics AX 2012 R2 POS. Microsoft Official Training Materials for Microsoft Dynamics 12-1

80 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization How to Modify the Trigger Project This lesson explains how to modify the triggers. To extend the triggers, you will use the operation triggers as an example and then customize these triggers. You will update the GiftCardBalance operation by asking the customer if he or she wants to add his or her balance after it is verified. Lesson Objectives Explain how to customize triggers and how the triggers are used. How to Modify the OperationsTrigger Project To modify the OperationsTrigger project, follow these steps. 1. Back up the existing assembly before any modification. If you must revert for any reason, the original assemblies will be available in such scenarios. 2. Browse to the folder where the Retail POS Software Development Kit (SDK) is installed. By default, it will be located at C:\Users\...\Documents\Retail SDK\POS Plug-ins\. 3. Open the Triggers folder and double-click the Triggers Visual Studio solution file. 4. Add a reference to the following assemblies that are located in the Retail POS runtime folder: o DevExpress.Utils.v11.2.dll o POSProcesses.dll o System.Windows.Forms.dll 5. Update the GiftCardBalance operation by asking the customer if he or she wants to add to his or her balance after it is verified. 6. Open the OperationTriggers.cs file and locate the PostProcessOperation method. 7. Add the following C# code: public void PostProcessOperation(IPosTransaction postransaction, PosisOperations posisoperation) { if (posisoperation == PosisOperations.GiftCardBalance) { using (var form = new LSRetailPosis.POSProcesses.frmMessage("Would you like to add to your gift card amount?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSForm(form); if (form.dialogresult == DialogResult.OK) 12-2 Microsoft Official Training Materials for Microsoft Dynamics

81 Module 12: Trigger Extensibility Sample and How-To to customer gift cards } } } else { { //reference existing or new logic for adding money LSRetailPosis.ApplicationLog.Log("IOperationTriggersV1.PostProcessOperatio n", "After the operation has been processed this trigger is called.", LSRetailPosis.LogTraceLevel.Trace); } } 8. After you build the project, put the assembly in the Retail POS\Services\Extensions folder. This path applies only to Microsoft Dynamics AX 2012 R2. For later versions, use POS\Extensions. 9. Start the POS runtime and perform the Gift card balance operation. 10. After you receive the balance, the dialog box appears with the customer message that is written in the post process. Microsoft Official Training Materials for Microsoft Dynamics 12-3

82 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 12-4 Microsoft Official Training Materials for Microsoft Dynamics

83 MODULE 13: SERVICES EXTENSIBILITY SAMPLE AND HOW-TO Module Overview Microsoft Dynamics AX 2012 includes a collection of core services that can be customized or replaced by using Retail POS Plug-ins. You can also create new services that can be started from existing services or triggers. Objectives Explain how to extend services in Microsoft Dynamics AX 2012 R2 POS. Microsoft Official Training Materials for Microsoft Dynamics 13-1

84 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization How to Modify the Services Project Services include one or more operations and implement a single, unique interface. You can make modifications to an existing service and continue to use the remaining functionality. Lesson Objectives This lesson explains how to modify the Z-Report by using EOD services project. How to Modify the Z-Report Example: If, in the Z-report, you want to print the count of a returned transaction in the shift, you can do the following: 1. Before the modification, take the backup of the existing assembly so that the original assemblies will then remain available if you must revert to them. 2. Browse to the folder where you installed the Retail POS Software Development Kit (SDK). By default, this folder will be located at C:\Users\...\Documents\Retail SDK\POS Plug-ins\. 3. Open the Services folder and double-click the Services Visual Studio solution file. 4. Browse to the EOD project and double-click the BatchPrinting.cs file and add the following new method: public static int CalculateReturnransactionCount(Batch batch) { int count = 0; DbConnection connection = ApplicationSettings.Database.LocalConnection; if (connection.state!= ConnectionState.Open) connection.open(); string query = "SELECT COUNT(S.TRANSACTIONID) FROM RETAILTRANSACTIONTABLE H INNER JOIN RETAILTRANSACTIONSALESTRANS S ON " + "H.TRANSACTIONID = S.TRANSACTIONID AND H.STORE = S.STORE AND H.TERMINAL = S.TERMINALID AND H.DATAAREAID = S.DATAAREAID " + "WHERE H.STORE " + "AND H.BATCHTERMINALID " + "AND H.DATAAREAID " + "AND H.BATCHID " + "AND S.QTY > 0"; using (DbCommand dbcommand = new SqlCommand()) { dbcommand.connection = connection; dbcommand.commandtext = query; dbcommand.parameters.clear(); 13-2 Microsoft Official Training Materials for Microsoft Dynamics

85 Module 13: Services Extensibility Sample and How-To if (batch!= null) { dbcommand.parameters.add(new SqlParameter("@STOREID", batch.storeid)); dbcommand.parameters.add(new SqlParameter("@BATCHTERMINALID", batch.terminalid)); dbcommand.parameters.add(new SqlParameter("@BATCHID", batch.batchid)); dbcommand.parameters.add(new SqlParameter("@DATAAREAID", ApplicationSettings.Database.DATAAREAID)); } count = DBUtil.ToInt32(dBCommand.ExecuteScalar()); } return count; 5. Locate the Print method (this Batch batch, ReportType reporttype) in the BatchPrinting.cs file and then add the following line of code after the line reportlayout.prepareheader(batch, reporttype); reportlayout.appendline(string.format("return count- {0}",CalculateNegativeTransaction(batch))); 6. After you do this, build the project and put the assembly in the Retail POS\Services\Extensions folder. This path applies only to Microsoft Dynamics AX 2012 R2. For later versions, use POS\Extensions. 7. Start the POS runtime and perform the Z-report operation to view the changes in the report. Microsoft Official Training Materials for Microsoft Dynamics 13-3

86 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 13-4 Microsoft Official Training Materials for Microsoft Dynamics

87 MODULE 14: BLANK OPERATION EXTENSIBILITY Module Overview You can use Blank Operations to extend Microsoft Dynamics AX for Retail Pointof-Sale (POS) by adding custom logic to the Retail POS register buttons. In the Retail POS register design layout, you can add any number of blank operation buttons and specify the operations information for each button. Later in this module, you will learn how to add a blank operation and specify the operation information. Objectives Explain how to create a blank operation and add it to POS layout. Microsoft Official Training Materials for Microsoft Dynamics 14-1

88 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Blank Operation on the Retail POS Register This lesson explains how to set up a blank operation and add custom logic to the blank operation Setting Up a Blank Operation on the Retail POS Register To set up a blank operation on the Retail POS register, follow these steps. 1. Start Retail POS. Right-click the Cashier Tasks button and then select Button Properties. The Configure button form opens. 2. In the Action drop-down list, select Blank Operation. The Operation number field is a string value that Retail POS uses to identify the Blank Operation. Because you can send multiple blank operations to Retail POS at the same time, you must give each blank operation a unique identity so that Retail POS can distinguish which blank operation to execute. You can use the Blank Operation param field to send an optional string parameter. The Operation number and Blank Operation param values combine to form the method signature of the Blank Operation. In this scenario, set the Operation number to MyTask and leave the Blank Operation param value to My Param. 3. You can use the fields under the Appearance tab on the right-side of the Configure button form to customize the appearance of the button. For example, you can set the text value that displays on the button when Retail POS is started. Change the button name to MyOperation, as shown in the following image: FIGURE 14.1 CONFIGURE BUTTON FORM 14-2 Microsoft Official Training Materials for Microsoft Dynamics

89 Module 14: Blank Operation Extensibility Adding Custom Logic to the Blank Operation To add custom logic to the Blank Operation, follow these steps. 1. Browse to the folder where you installed the Retail POS Software Development Kit (SDK). By default, it will be located at C:\Users\...\Documents\Retail SDK\POS Plug-ins\. 2. Open the Services folder and double-click the Services Visual Studio solution file. 3. Browse to the Blank Operations project and expand it. 4. Right-click the reference node and then click Add reference and browse for the assemblies POSProcessess in the Retail POS folder and then select it, and then click OK. 5. Open the BlankOperation.cs file and find the BlankOperation method, as shown in the following C# code example: public void BlankOperation(IBlankOperationInfo operationinfo, IPosTransaction postransaction) Notice the BlankOperation method takes two parameters: an operationinfo object and a postransaction object. The operationinfo object contains the MyTask operation number and the My Param operation parameter that you set on the MyOperation button of the Retail POS register. Retail POS uses that Operation number to identify the Blank Operation that is being passed. The postransaction object contains all the information about the current transaction. Several Blank Operations can be handled in the one BlankOperation method. Use a C# Switch statement on the operationinfo.operationid value to capture the specific Blank Operation that you must have. You can do this by adding the following code to the BlankOperation method. public void BlankOperation(IBlankOperationInfo operationinfo, IPosTransaction postransaction) { switch (operationinfo.operationid) { case "MyTask": //TODO: insert method call to your custom logic LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSStatusPanelText("My task operation is clicked"); operationinfo.operationhandled = true; break; } 6. Compile the BlankOperations project. 7. Copy your new assembly to the POS\Services\Extension folder and start Retail POS. This path applies only for Microsoft Dynamics AX 2012 R2. For later versions, use POS\Extensions. Microsoft Official Training Materials for Microsoft Dynamics 14-3

90 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 8. Click the Cashier Tasks button and then click the MyOperation button. You will receive the following message in the status panel: FIGURE 14.2: STATUS PANEL MESSAGE 14-4 Microsoft Official Training Materials for Microsoft Dynamics

91 MODULE 15: CUSTOM FIELDS ON POS LAYOUTS Module Overview This module explains how to add custom fields to Point-of-Sale (POS) layouts. In Microsoft Dynamics AX for Retail 2012 R2, you can also add custom fields on POS Receipt layouts. Objectives Explain how to add fields to the receipt layout. Microsoft Official Training Materials for Microsoft Dynamics 15-1

92 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Custom Fields on the POS Layout This lesson explains how to add fields to the receipt. You will learn how to add a line item field that shows the time that the item is added to a transaction and a header field that shows the total quantity of the whole transaction. Adding Fields to the Receipt Layout To create custom fields, follow these steps. 1. When you create the custom fields, as with the custom fields for till layout, receipt fields are defined in Headquarters on the Custom Fields form (Retail > Setup > POS > Profiles > Custom fields). For this example, you will create two fields, both of the type Receipt: TotalQty and TimeScanned. FIGURE 15.1: CUSTOM FIELDS FORM Any fields that are created in custom fields are available in all three sections of the receipt format designer Header, Lines, and Footer. The Caption text ID is a unique identifier for the text that will show in the receipt format designer (unlike the custom fields for till layout that use the Name in the designer, and the Caption text ID in the POS). The Caption text ID is still stored in the RetailLanguageText table and is only used at Headquarters. Because there is no form to add strings to the RetailLanguageText table, you will populate the values directly in the Application Object Tree (AOT). 2. Open a new developer workspace and browse to Data Dictionary > Tables > RetailLanguageText. Right-click and select Open Microsoft Official Training Materials for Microsoft Dynamics

93 Module 15: Custom Fields on POS Layouts 3. Create two records by populating the languageid, Text and textid fields: FIGURE 15.2: NEW DEVELOPER WORKSPACE To add the custom fields to the Receipt Layout, follow these steps. After the fields are created they can immediately be added to any receipt format. 4. Browse to Retail > Setup > POS > Receipt formats and then click the Designer button for any receipt format. Microsoft Official Training Materials for Microsoft Dynamics 15-3

94 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization FIGURE 15.3: RECEIPT FORMATS If the fields and labels are created correctly, you should be able to find them in the field list for any of the three sections: 15-4 Microsoft Official Training Materials for Microsoft Dynamics

95 Module 15: Custom Fields on POS Layouts FIGURE 15.4: RECEIPT FORMAT DESIGNER Note: You did not correctly create the RetailLanguageText record, if something appears that resembles (22000)??Missing String??. 1. Find a place to drag the Total Quantity and Time Scanned fields onto the header section and give each a hard-coded text label. Make sure that you press the Save button when you are finished. 2. Run the A-1090 or N-1090 job to push the new receipt to the POS database. Microsoft Official Training Materials for Microsoft Dynamics 15-5

96 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization FIGURE 15.5: RECEIPT FORMAT DESIGNER WITH TRANSACTION COMMENTS HIGHLIGHTED To connect the custom fields in code, follow these steps. 3. Before the modification, take the backup of the existing assembly so that the original assemblies remain available if you must revert to them. 4. Browse to the folder where you installed the Retail POS Software Development Kit (SDK). By default, it will be located at C:\Users\...\Documents\Retail SDK\POS Plug-ins\. 5. Open the Services folder and then double-click the Services Visual Studio solution file. 6. Locate the FormModulation.cs file in the Printing service. Values for the header and footer fields are handled in the GetInfoFromTransaction() method and for lines it is the GetInfoFromSaleLineItem() method. Locate the switch statement for GetInfoFromTransaction() from the following code example. switch (iteminfo.variable.toupperinvariant().replace(" ", string.empty)) { case "DATE": return ((IPosTransactionV1)theTransaction).BeginDateTime.ToShortDateString(); case "TIME24H": return 15-6 Microsoft Official Training Materials for Microsoft Dynamics

97 Module 15: Custom Fields on POS Layouts ((IPosTransactionV1)theTransaction).BeginDateTime.ToString("HH:mm"); 7. To print a value for the custom field, you have to add the field name to the switch statement. case "TOTALQTY": return thetransaction.saleitems.sum(s => s.quantity).tostring(); To use PartnerData fields for line items, follow these steps. The header example used a simple calculated field to print a value. However, you want to extend the RetailTransaction object to store extended values that can then be printed on the receipt. You can do this with the PartnerData object that is introduced in Microsoft Dynamics AX for Retail 2012 Feature Pack. The PartnerData object is a dynamic collection that can be defined at run time instead of compile time. Fields can be stored at the transaction level, the sales line level, or the payment line level. These fields are then stored in transaction object and can be used in triggers or services. In the example, you will create a field that is named TimeAdded on the sales line and then use it when you print the receipt. 8. Open the Triggers solution in Visual Studio and browse to the ItemTriggers project. Now you have to add several things to the project before you add the code. o o o The PartnerData object relies on a feature that is introduced in C# 4.0. To use PartnerData in any of the POS code, the project must add a reference to Microsoft.Csharp The example uses the SaleLineItem POS object. This object is in the Transaction class. The project also requires a reference to the Transaction.DLL file from the POS installation folder. Make sure that you set the Copy Local property to False when you add this reference. Finally, a using LSRetailPosis.Transaction.Line.SaleItem; line must be added to the top of the ItemTriggers.cs file. 9. After this is set up, you must add the following lines to the PreSale() method: using LSRetailPosis.Transaction.Line.SaleItem; [...] public void PreSale(IPreTriggerResult pretriggerresult, ISaleLineItem salelineitem, IPosTransaction postransaction) { SaleLineItem s = (SaleLineItem)saleLineItem; s.partnerdata.timeadded = System.DateTime.Now.ToString("HH:mm:ss"); Microsoft Official Training Materials for Microsoft Dynamics 15-7

98 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 10. Now you must read the TimeAdded value when you print sales lines on the receipt. This is performed in the FormModulation.cs again, this time in the GetInfoFromSaleLineItem() method. switch (iteminfo.variable.toupperinvariant().replace(" ", string.empty)) { case "TIMESCANNED": returnvalue = saleline.partnerdata.timeadded; break; case "TAXID": returnvalue = saleline.taxgroupid; break; 11. Compile the ItemTriggers.dll and Printing.dll and then copy them to the POS\Services\Extension subfolder in the POS installation. This path applies only to Microsoft Dynamics AX 2012 R2. For later versions, use POS\Extensions. 12. Start POS and print a receipt by doing a sale transaction so that you will able to view the modification in POS. Similar to this, you can also add custom fields on the following: Payment Grid Product Receipt Grid Totals Area 15-8 Microsoft Official Training Materials for Microsoft Dynamics

99 MODULE 16: REAL-TIME SERVICES EXTENSIBILITY SAMPLE AND HOW-TO Module Overview With Real-time Service, retail clients can interact with Microsoft Dynamics AX retail functionality in real time. You can extend Commerce Data Exchange: Real-time Service by adding extension methods to the RetailTransactionServiceEx class. The RetailTransactionServiceEx class is used as a service class between Microsoft Dynamics AX and the Point-of-Sale (POS). Objectives Explain how to extend Commerce Data Exchange - Real time service for POS. Microsoft Official Training Materials for Microsoft Dynamics 16-1

100 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Extending the RetailTransactionServiceEx Class To extend Real-time Service, you must create a new method in the RetailTransactionServiceEx class. All transaction service new methods should be created in this class. RetailTransactionServiceEx Class To extend the Real-time service, the methods must meet the following criteria: They must be a public static method. The return value must be a container of length two or more. The first two elements must be a Boolean value that indicates whether the method call is successful and a String value that you can use for a comment or error message. The other items in the container can be of any type. This includes nested containers. The method parameters must be one of the following Microsoft Dynamics AX primitive: o o o o o o o Boolean date int int64 str guid Real To add a method, follow these steps. Example: 1. In the Application Object Tree (AOT), right-click Classes > RetailTransactionServiceEx, point to New, and then click Method. 2. Add the custom business logic. The following example shows a method that takes a customer account number and returns a greeting message that uses the customer s name. For example, if customer account number 1001 is associated with a customer named Sandy, the method would return Hello Sandy! public static container Hello(AccountNum accountnumber) { CustTable custtable; DirPartyTable dirpartytable; container result = [false, '']; 16-2 Microsoft Official Training Materials for Microsoft Dynamics

101 Module 16: Real-Time Services Extensibility Sample and How-To if (accountnumber) { select firstonly Name from dirpartytable exists join custtable where custtable.accountnum == accountnumber && dirpartytable.recid == CustTable.Party; if (dirpartytable) { result = [true, 'Success!', strfmt("hello %1!", dirpartytable.name)]; } else { result = [false, 'Customer not found']; } } else { result = [false, 'accountnumber is null.']; } } return result; Here, you are calling the new method by using the POS BlankOperation. public void BlankOperation(IBlankOperationInfo operationinfo, IPosTransaction postransaction) { switch (operationinfo.operationid) { case "MyTask": try { var response = Application.Instance.TransactionService.InvokeExtension("Hello", "2014"); if (response.count == 1) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSStatusPanelText(response [0] as string); } } catch (CommunicationException ex) { LSRetailPosis.POSProcesses.POSFormsManager.ShowPOSStatusPanelText("Request failed: {0}", ex.message); } operationinfo.operationhandled = true; break; } } Microsoft Official Training Materials for Microsoft Dynamics 16-3

102 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization After you do this, compile the BlankOperations project and copy the new assembly to the POS\Services\Extension folder and then start Retail POS. This path applies only to Microsoft Dynamics AX 2012 R2. For later versions, use POS\Extensions. Click the Cashier Tasks button and then click the MyTask button. (Add the MyTask blank operation button if it is not yet added). For more information, refer to the blank operation extension document for how to add a custom blank operation button and how to customize this button). If the account number exists it will display the customer name on the status panel. To modify the existing methods in transaction service class (RetailTransactionService), add a new pre-event handler or a post event handler for that method and write the new method logic in the RetailTransactionServiceEx. Example: If a gift card is issued and you want to update a web service, create a new Post handler and set the class as RetailTransactionServiceEx and the method as UpdateGiftCardService. UpdateGiftCardService is the new method that is implemented in the RetailTransactionServiceEx class to update the gift card web service. public static void UpdateGiftCardService (XppPrePostArgs _args) { // All the gift card arguments can be fetched from the _args parameter // write your logic to update the service } To create a post handler, right-click the giftcardaddto method, and then select New Event Handler Subscription. Now, set the properties shown as follows: FIGURE 16.1: NEW EVENT HANDLER SUBSCRIPTION By doing it in this manner, both the existing code and the custom code are managed separately Microsoft Official Training Materials for Microsoft Dynamics

103 MODULE 17: POS PAYMENT CONNECTOR Module Overview Microsoft Dynamics AX 2012 R2 includes a unified payment processing architecture for processing credit card transactions. You can extend this architecture by creating your own payment connector. This payment connector can be used for a single assembly in three locations retail stores (POS registers), online stores, and the Microsoft Dynamics AX Accounts Receivable module. Microsoft Dynamics AX 2012 R2 includes one payment connector the Dynamics Payment Connector. This payment connector is used to connect to the Dynamics Online Payment Services provider. You can extend Payment Services to include an additional payment connector by implementing a specific interface. After you deploy a new payment connector, all the Microsoft Dynamics AX payment configuration pages will display the required fields to configure the payment connector. After you configure the payment connector, you can validate it, and then use it on a retail channel. The new payment connector can also support the new touch screen payment terminal devices. Objectives Disclaimer Explain how to create the payment connector to work on all Microsoft Dynamics channels for payment processing. You may copy, alter, adapt, modify or create derivative works of the Dynamics Payment SDK and this TemplateConnector for the purpose of payment card processing and use solely with Microsoft Dynamics AX 2012 R2 in your internal business operations and with valid licenses of Microsoft Dynamics AX 2012 R2. You will not, and will not permit or authorize any third party to distribute any of the derivative works of the Payment SDK and this TemplateConnector. Microsoft Official Training Materials for Microsoft Dynamics 17-1

104 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization Payment Connector You can use the payment connector to connect any Microsoft Dynamics channel to the payment SDK for processing payments. You can also use the payment connector to connect to different payment devices, such as Hydra. The payment connector extends from a different interface to achieve the functionality that is described earlier. Some components of the main interface are listed as follows: IPaymentManager The Microsoft.Dynamics.Retail.PaymentManager.Reference.IPaymentManager is the interface for all payment devices. It exposes the methods and events for handling devices. IPaymentProcessor The Microsoft.Dynamics.Retail.PaymentSDK.IPaymentProcessor is the interface for all the payment processing methods. It exposes the methods and events for handling payments. ISessionOperation The Microsoft.Dynamics.Retail.PaymentSDK.ISessionOperation is the interface for maintaining the session for processing. It exposes the methods and events for handling sessions. Some key methods of the payment connector include the following: Methods Authorize Refund Void Description Used to authorize the payment. Used to refund the payment. Used to Void the transaction Microsoft Official Training Materials for Microsoft Dynamics

105 Create a Payment Connector To create the payment connector, follow these steps. Module 17: POS Payment Connector 1. Install RetailPOS from the Microsoft Dynamics AX Setup and then unzip the TemplateConnector.zip file. For the TemplateConnector source code, download location and license information, refer to the Microsoft Software License Terms agreement and the developer and demonstration license agreement. 2. Open TemplateConnector.csproj by using Visual Studio. For Visual Studio requirements, refer the Development Environment Requirements document. 3. Right-click the TemplateConnector project and then click properties. Rename the assembly name to the name that you want the assembly to be called. 4. On the Signing tab, sign your assembly with a strong name key file. This is required if you want to deploy your payment connector to the GAC for the online store. Microsoft Official Training Materials for Microsoft Dynamics 17-3

106 Microsoft Dynamics AX 2012 R2 For Retail in Brick and Mortar Stores - Development and Customization 5. Open TemplateConnector.cs and change the following properties. List the countries that the connector supports. 6. Click View > Task List to display the task list. The task list shows all the elements that you should customize for payment Microsoft Official Training Materials for Microsoft Dynamics

107 Module 17: POS Payment Connector Custom Business Logic You can use the template as a basis for the payment connector. However, you must add custom business logic to make it function. The areas in the template that require your attention are marked as TODOs in the task list. For operations, such as authorize, capture, linked refund, and void, you must create logic to call out to your payment provider. The logic can use information from two places merchant properties as they are entered in Microsoft Dynamics AX (IP address, username, password, and so on) and the payment request for this transaction (card number, transaction amount, payment amount, and so on) that is provided by the application. The results of the call to the payment provider are then sent back to the application as a response object. Each of these is a key and, or value data structure. Map the payment request properties and the merchant properties to the data that is required by the provider. When the payment provider returns a response, the data should be extracted and entered in the variables as noted in the example. If you must store a stable state that is returned by the payment provider, you can create new properties in the response property bag. Then you can use these properties in future calls to the payment provider. Merchant properties contain metadata that Microsoft Dynamics AX uses to display a user interface (UI) to enter the values. The values that are entered by the user in Microsoft Dynamics AX are then automatically passed to the payment provider. In the example, there is a merchant property named IPAddress to show how this is performed. Microsoft Official Training Materials for Microsoft Dynamics 17-5