AX7/D365/Operations: Create customer postal address through data entity from .NET console application

Purpose:

The purpose of this document is to demonstrate how we can create customer postal addresses in Dynamics 365 for Finance and Operations using an external .NET console application.

Code:

static void Main(string[] args)
{
      Program program = new Program();
      Uri oDataUri = new Uri(ODataEntityPath, UriKind.Absolute);
      var context = new Resources(oDataUri);

      context.SendingRequest2 += new EventHandler(delegate (object sender, SendingRequest2EventArgs e)
      {
          var authenticationHeader = OAuthHelper.GetAuthenticationHeader(useWebAppAuthentication: true);
          e.RequestMessage.SetHeader(OAuthHelper.OAuthHeader, authenticationHeader);
      });

      program.testCustomerAddressCreate(context);
}
public void testCustomerAddressCreate(Resources _context)
{
      DataServiceCollection dataServiceCollection = new DataServiceCollection(_context);
      CustomerPostalAddress customerPostalAddress = new CustomerPostalAddress();

      dataServiceCollection.Add(customerPostalAddress);

      customerPostalAddress.CustomerLegalEntityId = "CPL";
      customerPostalAddress.CustomerAccountNumber = "C0000010";
      customerPostalAddress.AddressDescription = "Test address from OData 44.";
      customerPostalAddress.IsRoleBusiness = NoYes.Yes;
      customerPostalAddress.IsPostalAddress = NoYes.Yes;
      customerPostalAddress.AddressLocationRoles = "Address role";
      customerPostalAddress.AddressCountryRegionId = "AUS";
      customerPostalAddress.AddressZipCode = "2151";
      customerPostalAddress.AddressCity = "NORTH ROCKS";
      customerPostalAddress.AddressState = "NSW";

      DataServiceResponse response = null;

      try
      {
          response = _context.SaveChanges(SaveChangesOptions.PostOnlySetProperties);
      }
      catch (Exception ex)
      {
          Console.WriteLine(ex.Message + ex.InnerException);
      }

      Console.ReadLine();
}
Advertisements

AX7/D365/Operations: Enable/Disable form control in X++

Purpose:

The purpose of this document is to demonstrate how we can enable/disable a form control in X++ based on a business logic.

Product:

Dynamics 365 for Finance and Operations, Platform Update 9.

Development approach:

Customization through extension.

Development:

  1. Create a post event handler of a standard form method enabling/disabling the form controls. In this case, we are creating a post event handler of a standard method setFieldAccessHeader of SalesQuotationProjTable form.
  2. Please find the event handler method definition as follows.
[PostHandlerFor(formStr(SalesQuotationProjTable), formMethodStr(SalesQuotationProjTable, setFieldAccessHeader))]
public static void SalesQuotationProjTable_Post_setFieldAccessHeader(XppPrePostArgs args)
{
    FormRun             sender = args.getThis();
    FormDataSource      salesQuotationTable_ds;
    SalesQuotationTable salesQuotationTable;

    salesQuotationTable_ds = sender.dataSource(1);
    salesQuotationTable = salesQuotationTable_ds.cursor();

    sender.control(sender.controlId(formControlStr(SalesQuotationProjTable, DeviceUsageGroup))).enabled((salesQuotationTable.AMDeviceId) ? true : false);
}

AX7/D365/Operations: Create Details Master pattern form

Purpose:

The purpose of this document is to demonstrate how we can develop a Details Master form in Dynamics 365 for Operations. While doing so, it also shows how to apply the new form patterns and subpatterns.

Please note that the new Details Master pattern (Dynamics 365 for Operations) obsoletes the older ListPage pattern (AX 2012).

Prerequisites:

  • Access to Dynamics 365 for Operations instance via remote desktop.
  • To be provisioned as an administrator for the instance.
  • Visual Studio project, model, package have been created.
  • Custom table MAKInventRawMaterial has been created in the project.

Business requirement:

Ability to maintain records in a grid and detail view within the same form.

Development:

1. Click Ctrl+Shift+A to add new item to the project.
2. Navigate to User Interface > Form. Give a suitable name, MAKInventRawMaterial.

Form1

3. Drag and drop MAKInventRawMaterial table from the project to the Data Sources node.

Form2

4. Right-click Design node. Click Apply pattern > Details Master.

Form3

5. Once the pattern gets applied, open the Pattern pane to see the missing controls which need to be added to comply with the pattern.

Form4

6. Add the identified missing controls to the Design node in the same order as shown in the pattern tab.

Form5

7. As you can see after adding the required controls the violations have been but still there are some warnings.
8. Navigate to FormGroupControlNavigationList to view its Pattern tab. We still have missing controls for our Navigation List control.

Form6

9. Adding the identified missing controls resolves the pattern issues.

Form7

10. Repeat steps 6 – 9 till all the pattern and subpattern issues have been resolved by adding the missing controls. At the end of the process, you will have a completed form ready to add data source fields to.
11. Add the following field groups to the Details panel from data source table.

Form8DetailsTab

12. Add the AutoReport field group to the Grid control of the Grid panel.

Form9GridTab

13. Navigate to FormCommandButtonControl and set Command property to DetailsView.

Form10CommandButtonDetailsView

14. Navigate to FormGridControl and set Default Action property to the FormCommandButtonControl.

Form11GridDefaultAction

15. Right-click Project > Forms > MAKInventRawMaterial. Click Set as Startup Object.

StartupObject

16. Select project in your Solution Explorer and click Start in Visual Studio.
17. You should be able to see your form in action in the browser.
18. Grid view.

Form12GridView

19. Details view.

Form13DetailsView

AX7/D365/Operations: Create custom data entity

Purpose:

The purpose of this document is to demonstrate how we can develop a custom data entity for a custom table in Dynamics 365 for Operations.

Prerequisites:

  • Access to Dynamics 365 for Operations instance via remote desktop.
  • To be provisioned as an administrator for the instance.
  • Visual Studio project, model, package have been created.
  • Custom table has been created in the project.

Business requirement:

Ability to perform data operations on custom table.

Development:

We’ll be developing a data entity for a custom table, MAKInventRawMaterial for this scenario.

1. Click Ctrl+Shift+A to add new item to the project.
2. Select Data Model > Data Entity, giving name MAKInventRawMaterialEntity. Click Add.

DataEntity1

3. Specify data entity properties as shown below and select MAKInventRawMaterial table as the Primary datasource. Click Next.

DataEntity2

4. On the next screen of the wizard, review the data entity fields. You may choose to Convert labels to field names. Click Finish.

DataEntity3

5. The following highlighted development artifacts must be created.

DataEntity5

6. Open project properties and set Synchronize Database on Build to True to synchronize the newly created table and data entity with database.

DataEntity4

7. You have now successfully created a custom data entity!

To see the custom data entity in action, please see the following post.

https://dynamicsaxinsight.wordpress.com/2017/06/13/ax7-d365-operations-data-import-using-data-entities/

 

AX7/D365/Operations: Data import using data entities

Purpose:

The purpose of this document is to demonstrate how we can import data using data entities in Dynamics 365 for Operations.

Prerequisites:

  • Access to Dynamics 365 for Operations instance via remote desktop.
  • To be provisioned as an administrator for the instance.

Business requirement:

Ability to import/migrate legacy business data to Dynamics 365 for Operations.

Process:

1. Navigate to Workspaces > Data management > Import.
2. Enter job details as shown below. We have selected a custom data entity Raw material in this scenario. You can safely use any standard data entity instead.

DataEntity6

3. Click Upload to select and upload the source data file.
4. Click View map to generate field mappings.
5. On Map source to staging screen, click Mapping visualization.
6. Define the mapping. Click Save.

DataEntity7

7. Now go back to the job screen and click Import.
8. At the end of the execution, you should see the Execution summary.

DataEntity8

9. You can verify the data loaded by navigating to the relevant form. In this case Raw Materials details master form.

DataEntity9

AX7/D365/Operations: Create custom module

Purpose:

The purpose of this document is to demonstrate how we can create custom module in the main menu for Dynamics 365 for Operations.

Prerequisites:

  • Access to Dynamics 365 for Operations instance via remote desktop.
  • To be provisioned as an administrator for the instance.
  • Visual Studio project, model, package have been created.

Business requirement:

Ability to navigate to custom module.

Development:

1. Click Ctrl+Shift+A to add new item to the project.
2. Add new Menu, MAKDevelopmentBasics, click Add.

Menu1

3. Open the newly added menu in the designer.
4. Right click it to add a new Submenu, Common.

Menu2

5. Drag and drop a display menu item to the submenu.

Menu3

6. In the Application Explorer, navigate to MainMenu and create an extension.

Menu4

7. Give a suitable name to the extension, MainMenu.MAKDevelopmentBasics.

Menu5

8. Open the newly created extension in the designer.
9. Drag and drop the MAKDevelopmentBasics menu to the extension of MainMenu.

Menu6

10. You should be able to see the custom module added to the Modules of the Dynamics 365 for Operations application.

MenuResult

AX7/D365/Operations: Data export using data entities

DataManagement


Purpose:

The purpose of this document is to demonstrate how we can export data using out-of-band (OOB) data entities from Dynamics 365 for Operations.

Prerequisites:

  • Access to Dynamics 365 for Operations instance via remote desktop.
  • To be provisioned as an administrator or at least data management officer for the instance.

Business requirement:

Ability to export customer master for USMF legal entity.

Process:

1. Navigate to Workspaces > Data management.
2. Click Export tile.
3. Enter JOB DETAILS as follows. We have selected Customers data entity for this scenario.

Step1

4. Click Add entity button. You should see Customers data entity added to the right pane.
5. Click Export button.
5. After the job ends, you can see the count of records exported on the Execution summary screen.

Step3

6. Click the ellipsis button to download the file.

Step4

7. You should be able to see the exported records in the Excel file.

Result