No items found.

AIF testing in AX 2012

  1. From inside Dynamics AX using jobs:
    a. Testing only classes for creating records in database.
    b. Testing service classes and classes for creating records in database.
  2. Configuring and testing AIF service.

Testing only classes for creating records in database

Below is code for creating record in ProjTable.

static void ANG_AIF_TestServiceAX_1(Args _args)

{

  AifEntityKeyList                            entityKeyList;                          // Entity key list

  ProjTableService                            projTableService;                       // Service class

  ProjProjTable                               projProjTable;                          // Document object

  ProjProjTable_ProjTable                     projProjTable_ProjTable;                // data object;

  ProjProjTable_TableDlvAddr                  projProjTable_TableDlvAddr;             // data object

  // Create the service instance

  projTableService = ProjTableService::construct();

  // Create the data document object

  projProjTable = new ProjProjTable();

  projProjTable.createProjTable();                                                    // Create the data list

  projProjTable_ProjTable = projProjTable.parmProjTable().addNew();                   // Add data object instance to data list

  // Initialize the data instance

  projProjTable_ProjTable.parmProjId("P-000003");

  projProjTable_ProjTable.parmName("Test name");

  projProjTable_ProjTable.parmProjGroupId("FixWIP");

  projProjTable_ProjTable.parmType(ProjType::FixedPrice);

  projProjTable_ProjTable.parmProjInvoiceProjId("GTC-19154");

  projProjTable_ProjTable.parmStatus(ProjStatus::InProcess);

  // Create the top level record

  projProjTable_TableDlvAddr = new ProjProjTable_TableDlvAddr();

  // Addind lower level record

  projProjTable_TableDlvAddr.parmAddress("Test Address");

  projProjTable_TableDlvAddr.parmCountryRegionId("PL");

  projProjTable_ProjTable.createTableDlvAddr().add(projProjTable_TableDlvAddr);

  // Create data

  entityKeyList = projTableService.create(projProjTable);

  info("end");

}

Testing service classes and classes for creating records in database

Here first we need to get XML file:

static void  ANG_AIF_TestSerwiceXMLGet(Args _args)

{

  AxdProjTable                                axdProjTable;

  AifEntityKey                                aifEntityKey;

  Map                                         map;

  XMLDocument                                 xmlDocument;

  XML                                         XML;

  AifPropertyBag                              aifPropertyBag;

  FileName                                    fileName;

  fileName    = @"C:\Temp\output.xml";

  map         = new Map(Types::Integer, Types::Container);

  map.insert(fieldNum(ProjTable, ProjId), ['AA-0033']);

  aifEntityKey = new AifEntityKey();

  aifEntityKey.parmTableId(tableNum(ProjTable));

  aifEntityKey.parmKeyDataMap(map);

  try

  {

      axdProjTable    = new AxdProjTable();

      xml             = axdProjTable.read(aifEntityKey, null, new AifEndPointActionPolicyInfo(), new AifConstraintList(), aifPropertyBag);

      new FileIoPermission(fileName, 'rw').assert();

      xmlDocument = XMLDocument::newXml(XML);

      xmlDocument.save(fileName);

      CodeAccessPermission::revertAssert();

  }

  catch

  {

      throw error('Error in document service outbound');

  }

  info("end");

}

After that we should modify that file and run job:

static void ANG_AIF_TestSerwiceXML(Args _args)

{

  XmlDocument                                 xmlDocument;

  AxdProjTable                                axdProjTable;

  FileName                                    fileName;

  //feed the xml that was modified after exporting through exportxml job

  fileName = @"C:\Temp\Test1.xml";

  try

  {

      new FileIoPermission(fileName, 'r').assert();

      xmlDocument     = XmlDocument::newFile(fileName);

      axdProjTable    = new AxdProjTable();

      axdProjTable.create(xmlDocument.xml(), new AifEndPointActionPolicyInfo(), new AifConstraintList());

      CodeAccessPermission::revertAssert();

  }

  catch

  {

      throw error('Error in document service');

  }

  info("end");

}


If you modified xml file correctly then you should have new record in your database.

Zobacz inne

Jak wybrać firmę do audytu i optymalizacji Dynamics 365?

Czytaj artykuł
Text Link

Migracja z Dynamics AX do Dynamics 365: jak wybrać partnera, koszt i etapy (2026)

Czytaj artykuł
Text Link

Jak wybrać firmę do wdrożenia Dynamics 365: kryteria, koszt i etapy (2026)

Czytaj artykuł
Text Link
Wróć do wszystkich

Porozmawiajmy o Twoim projekcie

Napisz, z czym przychodzisz: wdrożenie, migracja, rozwój systemu albo pytanie, na które szukasz odpowiedzi. Wracamy z konkretną propozycją następnego kroku, nie z prezentacją handlową.

Dziękujemy za wiadomość!
Oops! Something went wrong while submitting the form.
Microsoft AI Builder
Microsoft Copilot Studio
No items found.
No items found.
No items found.