DMF export operation using X++ in D365 for operation(AX 7)

Hi Everyone,

We will see how we can call a DMF export data project using X++.

In AX 7 we can add import/export as a batch job. here i am going to call a export operation as a batch job using X++.

I am going to create a export data project called ‘Customer groups’ to export customer group records into excel.

Once the data project created save it. then, create a new class to call this data project.

public static void main(Args _args)
{
DMFDefinitionGroup definitionGroup;
DMFDefinitionGroupName definitionGroupId;

select firstonly definitionGroup where definitionGroup.DefinitionGroupName ==’Customer groups’;
if (definitionGroup)
{
definitionGroupId = definitionGroup.DefinitionGroupName;
}

if (!definitionGroupId)
{
throw error(“@DMF:ExportDataProjectNotSpecifiedError”);
}

V_CustomerGrpBatchJobExport batchExporter = new V_CustomerGrpBatchJobExport();
batchExporter.batchInfo().parmBatchExecute(NoYes::Yes);

batchExporter.parmDefinitionGroupName(definitionGroupId);
batchExporter.saveLast();

// initialize captions
str taskCaption = strFmt(“@DMF:DMFExportInBatchCaption”, definitionGroupId);
// job caption can be specified in the prompt
str userInputCaption = strLRTrim(batchExporter.batchInfo().parmCaption());
str jobCaption = userInputCaption? userInputCaption : taskCaption;

batchExporter.batchInfo().parmCaption(taskCaption);
batchExporter.batchInfo().parmBatchHeader().parmCaption(jobCaption);

// Indicate ready status for batch run
batchExporter.parmReadyForBatch(NoYes::Yes);

// Schedule batch
batchExporter.doBatch();
}

You can download the exported file from job history panel in Data management workspace.

The advantage here is, you attach this class to a action menuitem and add it into a menu.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s