Monday, April 25, 2022

Data management EXPORT operation using X++ in D365FO

         #DMF

        Query query;

        DMFEntityName entityName;

        boolean isGenerated = false;


        entityName = DMFEntity::findFirstByTableId(tableNum(BankPositivePayExportEntity)).EntityName;


            // Update query

            query = new Query(DMFUtil::getDefaultQueryForEntityV3(entityName));

            QueryBuildDataSource qbds = query.dataSourceTable(tableNum(BankPositivePayExportEntity));

            SysQuery::findOrCreateRange(qbds, fieldNum(BankPositivePayExportEntity, PositivePayNumber)).value(queryValue(bankPositivePayTable.PositivePayNum));


        // Export file

        DMFDefinitionGroupName definitionGroupName = strFmt('%1-%2', classStr(BankPositivePayExport), bankPositivePayTable.PositivePayNum);


        try

        {

            BankPositivePayFormat positivePayFormat = BankPositivePayFormat::findByFormatName(bankPositivePayTable.PayFormat);

            List xsltFileList = new List(Types::String);


            if (positivePayFormat.FileId != '')

            {

                xsltFileList.addEnd(this.copyTransformationFile(positivePayFormat));

            }


            DMFEntityExporter exporter = new DMFEntityExporter();

            fileId = exporter.exportToFile(

                entityName,

                definitionGroupName,

                '',

                positivePayFormat.DMFSourceName,

                #FieldGroupName_AllFields,

                query.pack(),

                curExt(),

                xsltFileList,

                true,

                false);


            if (fileId != '')

            {

                this.sendFileToDestination();

                DMFDefinitionGroup::find(definitionGroupName, true).delete();


                isGenerated = true;

            }

            else

            {

                // DMF execution failed and details were written to the execution log

                throw error("@CashManagement:DMFExportCallFailedToExecutionLog");

            }

        }

        catch

        {

            //

        }


        return isGenerated;

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...