Month: January 2016

AX 2012: LogisticsPostalAddress unknown value

Posted on

Problem:

I learned something new about DateEffective tables today. I had a customer requirement to store addresses in a Standard AX table, PdsApprovedVendorList. So I created a relationship between my table and LogisticsPostalAddress table, adding foreign key to LogisticsPostalAddress to my table. Then I added this field to a form and set ReplacementFieldGroup property of the control to LocationReference.

Everything worked as expected but the problem surfaced when user modified one of the addresses in the Global Address Book which were referenced in my table. The custom field began to show Unknown for the address that was updated by user.

Resolution:

1. Add new Reference Data Source of LogisticsPostalAddress to the data source of your table on the form.

Untitled

2. Add the following lines of code to the form’s init method:

legManufacturerAddress_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidFrom));
legManufacturerAddress_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidTo));
legManufacturerAddress_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId));

3. Add the following lines of code to the executeQuery() method of parent data source to which reference data source is added before super() call. In this case, it is PdsApprovedVendorList.

legManufacturerAddress_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
legManufacturerAddress_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(), DateTimeUtil::maxValue());

Reason:

LogisticsPostalAddress is a DateEffective table. When user modifies an existing address, system creates a new record instead of updating the existing record. That’s why references do not get resolved after address modification.

AX 2012: Process AIF Gateway Queue in X++

Posted on Updated on

AIF requires a batch job to be configured with a particular set of services to move messages into and out of the AIF gateway queue. To manually process messages in the AIF gateway queue, you can run the following job:

// Developed on 01 Jan 2016 by Muhammad Anas Khan
// Blog: dynamicsaxinsight.wordpress.com
// LinkedIn: pk.linkedin.com/in/muhammadanaskhan
// Description: Process AIF Gateway Queue manually
static void makProcessAIFGatewayQueue(Args _args)
{
    // Inbound
    new AifGateWayReceiveService().run();       // read the messages
    new AifInboundProcessingService().run();    // process the messages in queue

    // Outbound
    new AifOutboundProcessingService().run();   // process messages in queue
    new AifGateWaySendService().run();          // send messages
}