Thursday, November 7, 2019

Can’t stop DynamicsAXBatch service error

Admin User Provisioning Tool Error:
  1. If the Admin User Provisioning Tool gives error that can’t stop DynamicsAxBatch.
  2. Go to the Services,
  3. Find out the service with the name: Microsoft Dynamics 365 Unified Operations: Batch Management Service
  4. Stop it.
  5. Now register with the provisioning tool
  6. If you are unable to stop the DynamicsAxBatch Service. Then do the following steps in it:
  • Click the Start menu
  • Click Run or in the search bar type services.msc
  • Press Enter
  • Look for the service and check the Properties and identify its service name. Service name would be DynamicsAxBatch
  • Once found, open a command prompt. Type: sc queryex [servicename].
  • Press Enter
  • Identify the PID
  • In the same command prompt type: taskkill /f /pid [pid number]
  • Press Enter
For reference, see the following picture:
Now start the service and and register yourself in the Admin Provisioning Tool.

Thursday, October 31, 2019

Using a tempDB table in a Query

static void TempDB(Args _args)

{


    PurchLineMarkTmp    tmpUnionedResult;


    InventTable         inventTable;


    InventTableModule   inventTableModule;


    Query               query;


    QueryRun            queryRun;




    // Execute insert_recordset with TempDB table as a target


     insert_recordset tmpUnionedResult(PurchLine)


        select RecId from inventTable


            exists join inventTableModule


                where   inventTableModule.ModuleType == ModuleInventPurchSales::Sales


                    && inventTable.ItemId == inventTableModule.ItemId


                    && inventTableModule.Price != 0; 




    query = new query();


    query.addDataSource(tableNum(PurchLineMarkTmp));


    queryRun = new QueryRun(query);


    // Force queryRun to fetch from the right temporary table


    queryRun.setRecord(tmpUnionedResult);




    // Iterate all registered quantities


    while (queryRun.next())


    {


        tmpUnionedResult   = queryRun.get(tablenum(PurchLineMarkTmp));


        info (strFmt('%1', tmpUnionedResult.PurchLine));


    }


}




source: http://mafsarkhan.blogspot.com/2013/07/example-for-using-tempdb-table-in-query.html

Friday, May 31, 2019

Get Invoice Journal Id after posting Sales Invoice from multiple packing slips using X++

SalesFormLetter_Invoice SalesFormLetter;
TmpFrmVirtual           tmpFrmVirtual;
List                    il;
;
il = new List(Types::Record);
// insert each packing slip RecId into the TmpFrmVirtual table
for (i = 1; i <= conlen(PScontainer); i++)
{
            packingSlipRecId = conpeek(PScontainer, i);
            custPackingSlipJour = custPackingSlipJour::findRecId(packingSlipRecId);     

            tmpFrmVirtual.NoYes     = true;
            tmpFrmVirtual.TableNum  = custPackingSlipJour.TableId;
            tmpFrmVirtual.RecordNo  = custPackingSlipJour.RecId;
            tmpFrmVirtual.Id        = custPackingSlipJour.SalesId;
            ttsBegin;
            tmpFrmVirtual.insert();
            ttsCommit;
            // add record into the List
            il.addEnd(tmpFrmVirtual);
}
// post invoice from multiple packing slips
        salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice);
        salesFormLetter.printFormLetter(false);
        salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::PackingSlip, AccountOrder::None, false, false, false, false, il.pack());
        // get the posted invoice journal recid
        invoiceJourRecId    = salesFormLetter.getOutputContract().parmJournal().RecId;


or  get a container of posted journals

CustInvoiceTrans        custInvTrans;
Set                     postedJournalList;
Set                     allPostedJournals = new Set(Types::Record);
SetEnumerator           enumAllPostedJournal;
Set                     postedJournalTransList;
SetEnumerator           enumPostedJournalTransList;


postedJournalList   = Set::create(SysOperationHelper::base64Decode(salesFormLetter.getOutputContract().parmAllJournals()));
allPostedJournals   = Set::union(allPostedJournals, postedJournalList);
postedJournalTransList      = Set::create(SysOperationHelper::base64Decode(salesFormLetter.getOutputContract().parmJournalLines()));
enumPostedJournalTransList  = postedJournalTransList.getEnumerator();

while(enumPostedJournalTransList.moveNext())
 {
        custInvTrans      = enumPostedJournalTransList.current();
        // process the data here
 }




Thursday, May 30, 2019

Convert from Transaction currency to Accounting currency

CurrencyExchangeHelper  currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), _invoicejournal.InvoiceDate);

lineCharges = currencyExchangeHelper.calculateTransactionToAccounting(_invoicejournal.CurrencyCode, lineCharges, true);


Import an ISV licese file into Dev environment using Power Shell

 K:\AOSService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --setupmode importlicensefile --metadatadir K:\aosservi...