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.



Enjoy!


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.

SourceDocumentProcessor.submitSourceDocumentLinesForHeader


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!Dynamics.AX.Application.FormletterJournalPost.post() 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.


USE [AxDB]
GO
SELECT * from ENUMVALUETABLE
 join ENUMIDTABLE
 on enumid = id
 and ENUMIDTABLE.NAME = 'LedgerPostingType'


Voila


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.


USE [AxDB]
GO

SELECT journal.ACCOUNTINGCURRENCYAMOUNT, journal.POSTINGTYPE, enum.NAME as PostingTypeName
 FROM SUBLEDGERJOURNALACCOUNTENTRY as journal with (NOLOCK)
 JOIN ENUMVALUETABLE as enum
  ON journal.POSTINGTYPE = enum.ENUMVALUE
  JOIN SubledgerJournalEntry as sub with (NOLOCK)
  ON journal.SUBLEDGERJOURNALENTRY = sub.RecId
  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

C:\AOSService\PackagesLocalDirectory\Bin\AdminUserProvisioning.exe

Thursday, April 18, 2019

D365: Bug in Payment method lookup in Expense report form

You cannot select a payment method in an Expense report line, if you opt for any category containing comma separated value.



There is a bug in standard TrvExpenseLookupHelper class in paymentMethodLookupQuery method: it must use old good queryValue() method.


Otherwise you will get a few values instead of one in the range. Compare them before and after the fix.



[ExtensionOf(classStr(TrvExpenseLookupHelper))]
final static class avrTrvExpenseLookupHelper_Extension
{
    /// <summary>
    /// A fix for the standard method which does not treat comma separated cost type correctly
    /// </summary>
    /// <param name = "_costType"></param>
    /// <param name = "_excludeImportOnly"></param>
    /// <returns></returns>
    public static Query paymentMethodLookupQuery(TrvCostTypeEDT _costType, boolean _excludeImportOnly)
    {
        Query                   query = next paymentMethodLookupQuery(_costType, _excludeImportOnly);
        QueryBuildDataSource    qbPayMethod, qbValidatePayment;
        TrvCostType             trvCostType;

        trvCostType = TrvCostType::find(_costType);

        query = new Query();

        qbPayMethod = query.addDataSource(tableNum(TrvPayMethod));

        if (trvCostType)
        {
            query.queryType(QueryType::Join);

            qbValidatePayment = qbPayMethod.addDataSource(tableNum(TrvValidatePayment));
            qbValidatePayment.addLink(fieldNum(TrvPayMethod,PayMethod),fieldNum(TrvValidatePayment,PayMethod));
            qbValidatePayment.joinMode(JoinMode::ExistsJoin);
            //it should be converted by standard queryValue()
            qbValidatePayment.addRange(fieldNum(TrvValidatePayment, CostType)).value(queryValue(trvCostType.CostType));
        }

        if (_excludeImportOnly)
        {
            QueryBuildRange qbr = qbPayMethod.addRange(fieldNum(TrvPayMethod, AutomaticPayment));
            qbr.value(queryValue(NoYes::No));
            qbr.Status(RangeStatus::Hidden);
        }

        return query;
    }

}