Friday, June 8, 2018

Error on Data Entity General Journals Import in Dynamics 365 for finance and operations

Issue/Cause:

1.      In Data Entities, System is inserting GL journal lines without creating reference in header line. In import document (excel or CSV) input for journal name is invalid with master Journal Names setup. 

Resolution: (Code Fix) .BUG
Adding separate new validation method to validate journal Names (validateJournalName).

In default Method (copyCustomStagingToTarget) in LedgerJournalEntity, adding newly added validation method in to it.

Note: 
Overlay requires (Not recommended)
Contact MS support or else wait for until MS releasing this code bug fix

Code: 
//Add new method in LedgerJournalEntity
//Added by Sangeeth - start
private static void validateJournalName(DMFDefinitionGroupExecution _dmfDefinitionGroupExecution, DMFStagingValidationLog _log)
    {
        // Put any rows that are not in Ledger journal name into error state
        LedgerJournalName ledgerJournalName;
        LedgerJournalEntityStaging staging;

        LedgerJournalEntityLog entityLog;
       
        ErrorMsg error = "Journal Name is invalid";

        insert_recordset entityLog (LedgerJournalEntityRecId, ErrorMessage)
            select RecId, error from staging
            where staging.DefinitionGroup == _dmfDefinitionGroupExecution.DefinitionGroup
               && staging.ExecutionId == _dmfDefinitionGroupExecution.ExecutionId
               && staging.TransferStatus == DMFTransferStatus::NotStarted
            exists join ledgerJournalName
                where staging.JournalName != ledgerJournalName.JournalName;


        // write errors to DMF validation log
        update_recordset staging
            setting TransferStatus = DMFTransferStatus::Error
        exists join entityLog
            where staging.RecId == entityLog.LedgerJournalEntityRecId;

        FieldName fieldName = fieldStr(LedgerJournalEntityStaging, JournalName);
        TableName tableName = tableStr(LedgerJournalEntityStaging);
        TableName entityName = "@GeneralLedger:LedgerJournalEntityLabel";
        DMFSourceTarget sourceTarget = DMFSourceTarget::Target;

        insert_recordset _log (DefinitionGroupName, ExecutionId, StagingRecId, StagingTableName, StagingColumnName, SourceTarget, EntityName, ErrorMessage)
            select DefinitionGroup, ExecutionId, RecId, tableName, fieldName, sourceTarget, entityName from staging
        join ErrorMessage from entityLog
            where staging.RecId == entityLog.LedgerJournalEntityRecId;
    }

//Added by Sangeeth - End

//Add below code to validate in
method: copyCustomStagingToTarget

  
//Old code
LedgerJournalEntity::validateJournalType(_dmfDefinitionGroupExecution, log);
LedgerJournalEntity::validateAndUpdateExchangeRates(_dmfDefinitionGroupExecution, log);
LedgerJournalEntity::validateAccountTypes(_dmfDefinitionGroupExecution, log);

  
//Replace by
LedgerJournalEntity::validateJournalName(_dmfDefinitionGroupExecution, log);
LedgerJournalEntity::validateJournalType(_dmfDefinitionGroupExecution, log);
LedgerJournalEntity::validateAndUpdateExchangeRates(_dmfDefinitionGroupExecution, log);

LedgerJournalEntity::validateAccountTypes(_dmfDefinitionGroupExecution, log); 

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