Monday, November 25, 2013

Create location using X++

void CreateLocation(WMSAisleId aisleNo)
{
  WMSAisle WMSaisle;
   wmslocation _wmslocation;
  ;
   try
   {
      select forupdate WMSaisle where WMSaisle.aisleId == aisleNo && WMSaisle.inventLocationId == inventLocationId ;
      if(WMSaisle.RecId==0)
      {
         WMSaisle.clear();
         WMSaisle.initValue();
         WMSaisle.inventLocationId= inventLocationId;
         WMSaisle.aisleId= aisleNo;
         WMSaisle.name= strfmt("%1,aisle%2",inventLocationId,aisleNo);
         WMSaisle.insert();
      }
  }
    catch
    {
    Error(strfmt("Isle already exist %1,%2", inventLocationId,aisleNo));
    }
   select firstonly _wmslocation where _wmslocation.inventLocationId ==inventLocationId && _wmslocation.wMSLocationId == wmsLocationId;
          if(_wmslocation.RecId== 0)
          {
          _wmslocation.clear();
          _wmslocation.initValue();
          _wmslocation.aisleId=aisleNo;
          _wmslocation.wMSLocationId= wmsLocationId;
          _wmslocation.inventLocationId = inventLocationId;
           _wmslocation.insert();
          }
}

Tuesday, November 12, 2013

How to print PDF Order Confirmation report from Enterprise Portal?

How to print PDF Order Confirmation report from Enterprise Portal?
Content Id: 2028630
Status:  Approved
Version:  1.0
Language:  en-US
 Author:  EUROPE\czlangow
Modified:  6/3/2010
Confidentiality:  Partner
SR/Case No.: 110031755639381

Symptoms
How to print PDF Order Confirmation report from Enterprise Portal?
Cause
NA
Resolution
The example in application where PDF report is printed is printing invoices:
The toolbar (Dynamics Toolbar WebPart) EPCustInvoiceJournalInfoToolbar is called which you can find in AOT under Web -> Web Menus when you go further you will see that action menu "Show invoice copy" is connected to Url (AOT \ Web \ Web Menu Item \ Url) MenuItemName EPPurchInvoice.
EPPurchInvoice item is referring to: _layouts/ep/downloaddocument.aspx.

DownloadDocument.aspx you can find in AOT \ Web \ Web Files \ Static Files where you can find that it is connected with EPDocuGetWebLet class.

In class EPDocuGetWebLet in method runDocument you can see that it used EPSendDocument class.

EPSendDocument class is the clue here, actually it is method new of this class.

So if you want to print document for Order Information


What you need to do is:
Create new report based on SalesOrder and SalesLine tables.
Create new url in AOT \ Web \ Web Menu Items \ URLs
This new menu item in URL property you need to specify: _layouts/ep/downloaddocument.aspx.
In Web \ Web menus \ EPSalesTableInfoToolbar \ Actions create new “Menu item” and in property MenuItemName specify menu item created in step 2
In method init of class EPSendDocument you need to add new block in case section ie:
case tablenum(SalesTable):
mailAddress = SalesTable::find(record.(fieldnum(SalesTable,SalesId))).Email;
custAccountNum = record.(fieldnum(SalesTable,CustAccount));
documentTitle = fileName("DocumentTitle");
reportName = reportstr(your new report name created in step);
break;
Go to EP and refresh AOT
You will be able to see document after selecting new menu as PDF.
The reason why I do not recommend to use SalesConfirm report and writing or new one is following:
As you see in EPSendDocument class the records taken to report are from context (session). In Order information site you have in context SalesTable site so you would need to create custConfirmJournal table to give it to SalesConfirm report which is based on this table. So what you would have to do is similar to what is going on in class SalesFormLetter_Confirm. This is why I believe approach to create new report would be easier here.

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...