No items found.

Initialisation and validation of data contract in AX 2012

In following text you will find sample implementation. Members of this simple data contract are initialised with current date and validated in some manner, and if validation is failed, feedback information is presented to user. Please notice, that spoken logic is limited to context of data contract object only. If it requires broader context we can initialise data contract in controller and validate in operation, but that goes out of scope of this blog entry.

Infolog (2) error in SimpleService.run (2)

[DataContractAttribute]

class SimpleContract implements SysOperationInitializable, SysOperationValidatable

{

  StartDate startDate;

  EndDate endDate;

  [DataMemberAttribute]

  public StartDate parmStartDate(StartDate _startDate = startDate)

  {

      startDate = _startDate;

      return startDate;

  }

  [DataMemberAttribute]

  public EndDate parmEndDate(EndDate _endDate = endDate)

  {

      endDate = _endDate;

      return endDate;

  }

  public void initialise()

  {

      startDate = systemDateGet();

      endDate = startDate;

  }

  public boolean validate()

  {

      if (endDate < startDate)

      {

          return checkFailed("End date must be greater or equal to start date.");

      }

      return true;

  }

}

class SimpleService

{

  public void run(SimpleContract _contract)

  {

      info(strFmt("Date range: %1 - %2", _contract.parmStartDate(), _contract.parmEndDate()));

  }

}

class SimpleController extends SysOperationServiceController

{

  public static void main(Args args)

  {

      SimpleController controller;

      controller = new SimpleController();

      controller.parmClassName(classStr(SimpleService));

      controller.parmMethodName(methodStr(SimpleService, run));

      controller.startOperation();

 }

}

‍

See more

Migration

SAP ECC to Dynamics 365 migration for Irish companies: timeline and cost in EUR

Read article
Text Link
Managed services

Who can take over Dynamics 365 Finance and Operations application management for a company in Sweden?

Read article
Text Link
Migration

Dynamics AX 2012 to Dynamics 365 migration in Norway: timeline and cost

Read article
Text Link
Back to all

Looking for a Microsoft partner? Let's talk about your project

Work with a team that has delivered implementations and projects for dozens of companies. Schedule an introductory call and see:

How to tailor Dynamics 365 to your company's processes, rather than the other way around

Which areas are worth automating to save time and reduce costs

Here is the step-by-step implementation process with Anegis: from analysis to post-launch support

Select a meeting time
Thank you for your message!
Oops! Something went wrong while submitting the form.
Microsoft AI Builder
Microsoft Copilot Studio
No items found.
No items found.
No items found.