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;

Tuesday, April 12, 2022

Error On data entity -> The data value violates integrity constraints in D365FO

Error: The data value violates integrity constraints

Solution:

1. Remove blank lines on sample file, If any (If in case, CSV or excel) or  Copy content alone from EXCEL or CSV, Create new workbook and paste it

2. Check all mandatory fields value filled in on input file or not and also check any index violation (duplicate values/Record) 

Upload data from Excel in D365FO X++

 Action Menu Item: SAN_UploadExcelData Object type: Class Object: <Controller class name> Label: <> Class: Controller class clas...