XML Generation in Ax 2012 AIF


I have one requirement.

That is whenever user add a new record only that new record should come in xml.

As of now it is generating all the records which is available in teh table.

So how to identify the new record and generate as xml.

Can anybody help in this those who knows aif.

Hi Sona,

Welcome to DUG [:)]

By default AIF will try to send all the info that matches the query. For your requirement -

  • Create a flag in the record
  • When record gets created, leave this flag un-ticked
  • Select this flag after this record is generated from AIF

This will need some modification inside AIF.

Thinking about this requirement, you can also use ‘CreateDateTime’ property on the table. This should enable you to identify new records.


static void batchupdate(Args _args)
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbr1, qbr2;
QueryRun queryRun;
AifActionId actionId;
AifEndpointList endpointList;
BatchJob batchJob;
BatchJobHistory batchJobHistory;
Batch batch;
AifConstraintList aifConstraintList = new AifConstraintList();
AifConstraint aifConstraint = new AifConstraint();
PriceDiscAdmTrans priceDiscAdmTrans;
container c;
int counter =1 ;
str s;


select reverse batchJob
join batch
where batchJob.RecId == batch.BatchJobID
&& batchJob.Status == BatchStatus::Finished
&& batch.ClassNumber == className2Id(‘PriceListServiceVariant_Halston’);

query = new Query(querystr(AxdPriceDiscountJournalVariant_Halston));
qbds = query.dataSourceTable(tableNum(PriceDiscAdmTrans));
qbr1 = qbds.addRange(fieldNum(PriceDiscAdmTrans, RecId));
//qbr2 = qbds.addRange(fieldNum(PriceDiscAdmTrans, ModifiedDateTime));
queryRun = new queryRun(query);
priceDiscAdmTrans = queryRun.get(tableNum(PriceDiscAdmTrans));
if (priceDiscAdmTrans.modifiedDateTime)
if (priceDiscAdmTrans.modifiedDateTime > batchJob.StartDateTime)
s = s + int642str(priceDiscAdmTrans.RecId);
s = s+’,’;
if (priceDiscAdmTrans.createdDateTime > batchJob.StartDateTime)
s = int642str(priceDiscAdmTrans.RecId);
s = s+’,’;


actionId = AifSendService::getDefaultSendAction(classnum(SalesPriceService), AifSendActionType::SendByQuery);
endpointList = AifSendService::getEligibleEndpoints(actionId, aifConstraintList);
AifSendService::submitFromQuery(actionId,endpointList, query, AifSendMode::Async);


I am using File system adapter for outbound port and i am comparing the modified date time if there is any modified records and created date time when there is a new record.

Just tell me wheather it is correct or not.


Is there any other way other than comparing the created date time and Modified date time.