Skip to main content

Dynamics 365 eCommerce - Setting up the Development Environment

Microsoft Dynamics 365 Commerce is an evolution of Dynamics 365 Retail, which launched with new and improved capabilities for e-commerce, content management. To begin development and extension on Dynamics 365 eCommerce we'll need to install the following tools on the development machine:

(Note that development on eCommerce is only supported on Windows (as at 18/06/20).)

Create a folder in your local drive to hold the e-Commerce site code - 'C:\repos'

Open CMD in administrator mode and go to the folder directory you just created and clone the Microsoft eCommerce repository with the following command: 

git clone https://github.com/microsoft/Msdyn365.Commerce.Online.git


This may take a while. Next, go inside the newly created folder C:\repos\Msdyn365.Commerce.Online' and run 'yarnto resolve conflicts and get latest dependency packages:



This command can take several minutes to run.  Once complete you should see something similar to the following screenshot:


(Note: if you get “would clobber existing tag” warnings ,run “yarn cache clean”)


Once this has been resolved, open 'C:\repos\Msdyn365.Commerce.Online\node_modules\@msdyn365-commerce-modules' in file explorer to view Microsoft's standard modules that come with the package.



To begin development, Open the 'Msdyn365.Commerce.Online' folder in VS Code. Ensure that your CMD is running in administrator mode and it's file directory should be pointing to 'Msdyn365.Commerce.Online' , i.e 'C:\repos\Msdyn365.Commerce.Online'


Creating modules

To add a new module, run ‘yarn msdyn365 add-module MODULE_NAME’ command. For example, the following command creates a module that is named ‘yourmodulename’:

    yarn msdyn365 add-module yourmodulename

or to clone a standard module :

     yarn msdyn365 standardmodulename yourmodulename

e.g yarn msdyn365 clone text-block mytextblock 


Module anatomy
The following files will be added to 'C:\repos\Msdyn365.Commerce.Online\src\modules\yourmodulename'
  • yourmodulename.definition.jsonThis file is referred to as the module definition file which is used to register the module and provides metadata to the site builder tool including the module name, description and category.
  • yourmodulename.data.tsThis data.ts file contains the typing's for data actions that are used by the module to fetch data. Once a data action gets its data it is stored in the properties in this file. 
    You can point your local dev environment to the retail server to load data from the server directly during development through the .env file.Here you will set the retail server link and env details, you can follow the extensibility guide to get this values from the back office and set it here (The .env file configuration is discussed later). Once the .env file is configured, you can configure your development site data to be loaded by calling the action methods from this data file. The action method will make the API call and get the data. 
    You can also set mock data for the development env in the mock data file.
  • yourmodulename.tsxThis file is a React component that controls the module’s view model and calls the module view. You’ll find a React “render()” method with some default embedded HTML.
  • yourmodulename.view.tsxThis file is the component that controls the module’s view. Additional module views can be provided in various themes to render a module differently depending on the requirements of the theme.

  • mocks/yourmodulename.json: This json file under the “mocks” directory is used to configure mock data for your module to be tested locally. When modules are run on a production server this data comes from the Dynamics CMS database as configured by the page authors instead of the mock file.

  • yourmodulename.props.autogenerated.ts : This file is an auto generated typescript file that should not be manually touched. Adding new configuration values to your module definition file and saving the file will automatically rebuild this file with appropriate interfaces. The interfaces in here can be accessed via the module view and react files as needed
Preview modules
To run the Node app, execute the command ‘yarn start’. This command may take a couple of minutes to execute, and you will see an output that indicating that the server has been started once the command completes execution.


To test that your Node app is running correctly, open the following URL in a web browser: localhost:4000/modules?type=yourmodulename

The allocated port number is 4000 by default. You may configure the port number in the .env file. To add more designs and contents to the module, you may refer to the ‘Designing our Module’ section of the ‘Dynamics 365 Commerce Online Developer Extensibility Getting Started Guide’ and follow Microsoft documentation on module creation at:

https://docs.microsoft.com/en-us/dynamics365/commerce/e-commerce-extensibility/create-new-module

Additional Notes

Configure development environment (.env) file

The. env is a simple configuration text file that is provided as part of the Dynamics 365 Commerce online software development kit (SDK). It defines the set of variables and data sources that can be used by the Node app that runs on the development environment. You may follow the following Microsoft documentation to configure the .env file and point to specific server/environment to retrieve and load data from

https://docs.microsoft.com/en-us/dynamics365/commerce/e-commerce-extensibility/configure-env-file

Written by: Patrick Sharma, Developer, Microsoft Dynamics 365 F&O, Retail & Commerce

Comments

Post a Comment

Popular posts from this blog

Conditionally Hiding Menu Items in D365 FinOps Menus Without Using Feature Keys

In Microsoft Dynamics 365 Finance and Operations (D365 F&O), menu items are the links that can be clicked on to access forms, reports, classes, jobs, and queries. Feature keys are typically used to control the visibility of menu items based on user licenses. However, there are scenarios where you might want to hide menu items conditionally without relying on feature keys.  This can be accomplished by extending the 'SysMenuNavigationObjectFactory' class and modifying the checkAddSubMenu(...) method.  Suppose we want to hide the  Vendor payment journal menu item under Accounts payable > Payments > Vendor payment journal Steps 1. Create an extension of the SysMenuNavigationObjectFactory class [ ExtensionOf ( classStr (SysMenuNavigationObjectFactory))] internal final class SysMenuNavigationObjectFactory_PS_Extension { } 2. Create a Chain of Command (CoC) for the checkAddSubMenu method [ ExtensionOf ( classStr (SysMenuNavigationObjectFactory))] internal final...

Electronic reporting (ER) - Create custom destinations

Electronic reporting (ER) is a configurable tool in Microsoft Dynamics 365 that helps create and maintain regulatory electronic reporting and payments. Configuration of reports can be done by business users with the use of Visual Editors without the need for developers. Refer to Electronic reporting (ER) overview - Finance & Operations | Dynamics 365 | Microsoft Docs for more information and detailed overview on ER. Destinations can be configured for each ER format configuration and its output component. Destinations can only be set up for ER configurations that have been imported into the current Finance instance, and for the formats that are available on the Electronic reporting configurations page. The functionality for ER destination management is available at Organization administration > Electronic reporting > Electronic reporting destination.  Microsoft Dynamics 365 for Operations version 1611 (November 2016) or later allows the use of  the following destinat...