Wednesday, November 29, 2017

Max number of sessions in WHS Dynamcs Ax 2012 R3

When we implemented a WHS module in Dynamics Ax 2012 R3, we experimented some issues but the most stressfull issue was the WHS web service crashed with five or six concurrent users.

I tought it was a configuration parameter about limit of conecctions, but i didnt know wich parameter, maybe an IIS parameter or AIF parámeter, was the second.

First of all, we have to select the follow menú: System Administration/ Setup / Services and Application Integration Framework/ EndPoints










In the endpoints form we are going to filter the whs* as the follow image show



We are going to desactivate the endpoint and then we clic the setup button and then, if we don’t have the right software tool to edit the file, the notepad Will open the file.

The netTCPBinding node has a maxConnections parameter but it was useless in this scenario.
But ServiceThrotting parameter had the solution, we had 200 in values of maxCurrentCalls, maxCurrentInstances, maxCurrentSessions



So, each users made several petitions to the service, even a user who refreshed the webpage repeatly



Just we increased the value of each parameter and we notice the website was supported more users tan before.


It really works for us!

See you!

Tuesday, November 28, 2017

Saving a Dynamics Ax Report to PDF

Hi guys!

I am gonna show you how to save a Dynamics Ax Report to PDF file.

We are going to use de getTempPath() method from WinApi class for getting the tmp directory.

static void saveProdId()
{
    ReportRun report;
    Args args;
    ProdBOM prodBOM;
    FilePath  path;
   ProdId  prodId;
    ;

    path = WinAPI::getTempPath();
    prodId= 'ProdIdNumber';

    select prodBOM where prodBOM.ProdId == prodId
            && prodBOM.ProdLineType == BomType::Vendor;


    args =  new Args();
    args.name(reportStr(SomeReport));
    args.record(prodBOM);
    report = ClassFactory.reportRunClass(args);
    report.printJobSettings().setTarget(PrintMedium::File);
    report.printJobSettings().preferredTarget(PrintMedium::File);
    report.printJobSettings().format(PrintFormat::PDF);
    report.printJobSettings().fileName(path + prodId  + '.pdf');
    report.query().interactive(false);
    report.run();


}

See you!

Monday, November 13, 2017

Using Infolog Ax 2012 R3

In this post you can learn how to use InfoLog class for sending a beautiful and professional messages in Dynamics Ax, however final user could not notice your effort.

static void testJCAinfo(Args _args)
{

    SetPrefix("Grandpa");
    SetPrefix("Dad");
    SetPrefix("Me");
    Infolog.add(Exception::Warning,"Puppy");
}

And the result is:



Now you have the power to agroup the info messages in Ax, but you can give more functionally if you want. check the code below


static void Test(Args _args)
{
      SysInfoAction_FormRun    infoAction =       SysInfoAction_FormRun::newFormName(formStr(EcoResProductDetailsExtended)); //Which form?

    
    infoAction.parmCallerBuffer(InventTable::find('TEST5')); // which record??
    
    Infolog.add(Exception::Warning,"El artículo no está propiamente configurado",'',infoAction);

}


First, we got the itemid with errors (TEST5)

In the message infolog we select the message


Notice a new button is appear automatically, and if you click on it, Ax shows you the EcoResProductDetailsExtended with the TEST5 Item.





Wednesday, November 1, 2017

Using RoundUp and RoundDown

Sometimes we would need to round a number, in this case you can use global method roundUp or rounDown.


static void roundExample()
{

    info(num2expstr(roundUp(6.5 ,1)));
  
}


The result is 7, 

This morning I was in trouble using this function... the result was 6 instead 7 such as if I would using roundDown,  some minutes later I notice I was tryng rounding a negative number LOL.



Thursday, October 19, 2017

Creating a purchPackingSlip from Code X++

Hi there!


In this code i'm showing you how to create a purch packing slip from code...


private void createPackingSlip(PurchId _purchId,packingSlipId _packingSlipId, Qty _qtyToReceive)
{
    PurchFormLetter             purchFormLetter;
    PurchFormletterParmData     purchFormLetterParmData;
    PurchParmUpdate             purchParmUpdate;
    PurchParmTable              purchParmTable;
    PurchParmLine               purchParmLine;
    PurchTable                  purchTable;
    PurchLine                   purchLine;
    PurchId                     purchId;
    Num                         packingSlipId;
   Qty                            qtyToReceive;


    purchId       = _purchId;
    packingSlipId = _packingSlipId;
    purchTable    = PurchTable::find(purchId);
   qtyToReceive = _qtyToReceive;

    ttsBegin;
    // Create PurchParamUpdate table
    purchFormLetterParmData = PurchFormletterParmData::newData(
        DocumentStatus::PackingSlip,
        VersioningUpdateType::Initial);

    purchFormLetterParmData.parmOnlyCreateParmUpdate(true);
    purchFormLetterParmData.createData(false);
    purchParmUpdate = purchFormLetterParmData.parmParmUpdate();

    // Set PurchParmTable table
    purchParmTable.clear();
    purchParmTable.TransDate                = SystemDateGet();
    purchParmTable.Ordering                 = DocumentStatus::PackingSlip;
    purchParmTable.ParmJobStatus            = ParmJobStatus::Waiting;
    purchParmTable.Num                      = packingSlipId;
    purchParmTable.PurchId                  = purchTable.PurchId;
    purchParmTable.PurchName                = purchTable.PurchName;
    purchParmTable.DeliveryName             = purchTable.DeliveryName;
    purchParmTable.DeliveryPostalAddress    = purchTable.DeliveryPostalAddress;
    purchParmTable.OrderAccount             = purchTable.OrderAccount;
    purchParmTable.CurrencyCode             = purchTable.CurrencyCode;
    purchParmTable.InvoiceAccount           = purchTable.InvoiceAccount;
    purchParmTable.ParmId                   = purchParmUpdate.ParmId;
    purchParmTable.insert();

    // Set PurchParmLine table
  
    select purchLine
        where purchLine.PurchId == _purchId;

    purchParmLine.InitFromPurchLine(purchLine);

    purchParmLine.ReceiveNow    = _qtyToReceive;
    purchParmLine.ParmId        = purchParmTable.ParmId;
    purchParmLine.TableRefId    = purchParmTable.TableRefId;
    purchParmLine.setQty(DocumentStatus::PackingSlip, false, true);
    purchParmLine.setLineAmount();
    purchParmLine.insert();


    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
    purchFormLetter.transDate(systemDateGet());
    purchFormLetter.proforma(false);
    purchFormLetter.specQty(PurchUpdate::All);
    purchFormLetter.purchTable(purchTable);

    
    purchFormLetter.parmParmTableNum(purchParmTable.ParmId);
    purchFormLetter.parmId(purchParmTable.ParmId);
    purchFormLetter.purchParmUpdate(purchFormLetterParmData.parmParmUpdate());
    purchFormLetter.run();
    ttsCommit;

}


I hope this will be useful.