Thursday, May 30, 2019

Overcome 'The natural key for the table TableName was not found' while creating data entity

When we need to create a data entity for a table without a natural key, say VendTrans, Data entity Wizard shows the following error.

In order to overcome this limitation, we can simply feed the wizard with a copy of a query table with a natural key added. Lately we can just replace one field and its related relation and index in the data entity and staging table.

So, find VendTrans table and create a copy into your model. Delete all methods, add new String field f, make a new unique index based on this field and make this index primary and clustered. You do not need either build or synchronize your solution yet.

Now run the Wizard again with VendTransCopy as a source, and you will get all needed objects created.

Go to data entity view and change its query data source to VendTrans table.

Then rename field f to something meaningful as VendTrans_RecId and point it to VendTrans.RecId.

Add a new Int64 field with the same name in the related staging table

Then use it instead of field f in the index and relation.

You can delete field f as well as VendTransCopy table.

That is it! Now build and synchronize the solution. The new data entity is ready for use.

Wednesday, May 8, 2019

How to change status for multiple batch jobs at once

All you need to change status for multiple batch jobs at once is to move the Change status button from its menu to any place in the grid tab.


Friday, May 3, 2019

D365 bug: The transactions on voucher do not balance. Process source document lines in parallel

The transactions on voucher do not balance as per 5/3/2019. (accounting currency: -13.34 - reporting currency: -13.34)

Does it look familiar? Yes, it still happens in D365, while you try to post a partial invoice matching one of product receipts.

A simple scenario. We confirmed a purchase order with one line of quantity 3 and price $10. Receive 1 and then 2. Then try to invoice the first line only.

If you get this error, it is probably because of the general ledger parameter.

Switch it off and try again.

Technical details. Unfortunately I did not manage to find an exact reason, but what I can see is that there are two different ways of creation accounting distribution.


When it comes to the parallel creation via TransitionRequest, D365 generates some unbalanced debit and credit records (on the left), but it does not happen when you post a full invoice against both receipts at once (on the right).

There is another article about this parameter, which can be of your interest, too.

The call stack for the aforementioned method call.

> Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentStateInProcess.transitionSourceDocumentLines() Line 592 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentStateInProcess.`doTransition() Line 132 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentStateBase.`transition() Line 196 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentStateBase.`performTransitionOrMaintenance() Line 133 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentStateBase.transitionTo() Line 290 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentProcessorBase.`submit() Line 133 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentProcessor.`submit() Line 231 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentProcessor.`submitSourceDocumentImplementation(Dynamics.AX.Application.SourceDocumentHeaderImplementation _sourceDocumentImplementation, bool _updateImplementation, Dynamics.AX.Application.SourceDocumentAccountingStatus _targetSourceDocumentAccountingStatus, Dynamics.AX.Application.SourceDocumentProcessorCaller _caller, Dynamics.AX.Application.SourceDocumentLineItemList _sourceDocumentLineItemList, string _user, bool _doTransitionToCompletedStateAccountFullyQualifiedValidation, bool _doAsynchronousLineProcessing, bool @_updateImplementation_IsDefaultSet, bool @_targetSourceDocumentAccountingStatus_IsDefaultSet, bool @_caller_IsDefaultSet, bool @_sourceDocumentLineItemList_IsDefaultSet, bool @_user_IsDefaultSet, bool @_doTransitionToCompletedStateAccountFullyQualifiedValidation_IsDefaultSet, bool @_doAsynchronousLineProcessing_IsDefaultSet) Line 378 X++
  Dynamics.AX.SourceDocumentation.1.netmodule!Dynamics.AX.Application.SourceDocumentProcessorFacade.`submitSourceDocumentImplementation(Dynamics.AX.Application.SourceDocumentHeaderImplementation _sourceDocumentImplementation, bool _updateImplementation, Dynamics.AX.Application.SourceDocumentAccountingStatus _targetSourceDocumentAccountingStatus, Dynamics.AX.Application.SourceDocumentProcessorCaller _caller, string _user, bool _doTransitionToCompletedStateAccountFullyQualifiedValidation, Dynamics.AX.Application.SourceDocumentLineImplementationList _sourceDocumentLineImplementationList, bool _doAsynchronousLineProcessing, bool @_updateImplementation_IsDefaultSet, bool @_targetSourceDocumentAccountingStatus_IsDefaultSet, bool @_caller_IsDefaultSet, bool @_user_IsDefaultSet, bool @_doTransitionToCompletedStateAccountFullyQualifiedValidation_IsDefaultSet, bool @_sourceDocumentLineImplementationList_IsDefaultSet, bool @_doAsynchronousLineProcessing_IsDefaultSet) Line 245 X++
  Dynamics.AX.ApplicationSuite.83.netmodule!Dynamics.AX.Application.PurchInvoiceJournalPost.`endLedgerVoucher() Line 1333 X++
  Dynamics.AX.ApplicationSuite.36.netmodule! Line 1622 X++
  Dynamics.AX.ApplicationSuite.36.netmodule!Dynamics.AX.Application.FormletterJournalPost.`run() Line 2277 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`postJournal(Microsoft.Dynamics.Ax.Xpp.Common _parmTable) Line 714 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`createAndPostJournal() Line 1708 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`processJournal(Dynamics.AX.Application.Printout _printout) Line 1684 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`processFormLetterParmTable(Dynamics.AX.Application.Printout _printout) Line 1476 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`runSingleThread(Dynamics.AX.Application.Printout _printout) Line 1508 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`run() Line 1634 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormletterService.`postPurchaseOrderInvoice(Dynamics.AX.Application.PurchFormLetterInvoiceContract _contract) Line 836 X++
  [External Code] 
  Dynamics.AX.ApplicationFoundation.9.netmodule!Dynamics.AX.Application.SysOperationServiceController.runOperationInstance(Dynamics.AX.Application.SysOperationServiceController controller) Line 780 X++
  Dynamics.AX.ApplicationFoundation.9.netmodule!Dynamics.AX.Application.SysOperationServiceController.runOperationSynchronously() Line 695 X++
  Dynamics.AX.ApplicationFoundation.9.netmodule!Dynamics.AX.Application.SysOperationServiceController.`run() Line 581 X++
  Dynamics.AX.ApplicationSuite.37.netmodule!Dynamics.AX.Application.FormLetterServiceController.`run() Line 847 X++
  Dynamics.AX.ApplicationSuite.83.netmodule!Dynamics.AX.Application.PurchFormLetter.`run() Line 1526 X++
  Dynamics.AX.ApplicationPlatform.4.netmodule!Dynamics.AX.Application.SysOperationSandbox.operationExecutionWrapper(object[] serializedOperation) Line 311 X++
  [External Code] 

How to see enum values in D365

Enum values are unavailable anymore in D365. But we can still find them via SQL.

There are two tables of our interest: EnumValueTable with actual values and EnumIdTable with IDs; the latter can be found by a given name, for example, for LedgerPostingType.

 on enumid = id
 and ENUMIDTABLE.NAME = 'LedgerPostingType'


How to see SubledgerJournalEntry records not committed yet by ttsCommit()

Sometimes we want to see records before they are inserted into data base. We can do it on the SQL side by means of with (NOLOCK) option.

Let's say we are debugging creation of SubledgerJournalEntry records. Place the following code in a new query in SQL Management Studio.


  JOIN SubledgerJournalEntry as sub with (NOLOCK)
  where sub.ACCOUNTINGEVENT = 5637159590
  AND enum.ENUMID = 1811

SELECT SubledgerJournalEntry, SUM(TransactionCurrencyAmount) as sumTrans, SUM(AccountingCurrencyAmount) as sumAcc, SUM(ReportingCurrencyAmount) as sumRep FROM 
SubledgerJournalAccountEntry with (NOLOCK)

inner join SubledgerJournalEntry with (NOLOCK)
on SubledgerJournalAccountEntry.SubledgerJournalEntry = SubledgerJournalEntry.RecId
and SubledgerJournalEntry.ACCOUNTINGEVENT = 5637159590
GROUP BY SubledgerJournalAccountEntry.SubledgerJournalEntry

So, now we can see it before they are committed by ttsCommit().

Thursday, May 2, 2019

Where to check your D365 version

D365 Provisioning Admin User