Thursday, April 15, 2021

D365FO Data Management - Import/Export Container Data Fields

Implement the logic for convert "container field" data bounded value into the base64 string during the data export.

Table Field -> ConImage

Data Entity Field -> 

Create two new unmapped field as 

ConImageStr

Method: Data entity methods -> POST LOAD

//Export - start

//Post load to export data container information to str

if (this.ConImage)

{

    container conValue;

    str containerAsString;

    conValue= this.ConImage;

    containerAsString = con2base64str(conValue);

    this.ConImageStr = containerAsString;


}

//Export - End


//Import code  - start

//Use method -> defaultRow()

str containerAsString;

Container conValue;

containerAsString = this.ConImageStr;

conValue= base64str2con(containerAsString);

this.ConImage= conValue;

//Import code  - End


In the case of a container with binary content, add one more string field to the staging table, for exporting the Memo field.

The field should extends FileName EDT 

Field name: conImageStrFileName

Implement data entity method


When exporting this DMF data entity, ConImageStr will be packaged into separate files.

public static container getFieldsToBeConvertedToFile()

{

    return [fieldstr(<EntityName>, ConImageStr),

            fieldstr(<StagingTableName>, ConImageStr),

            fieldstr(<StagingTableName>, ConImageStrFileName),

            true];

}


Create export project and export now

Download package

Unzip package file

Resource folder with all container contents exported as separate files.





No comments:

Post a Comment

Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...