Posts

Model import error - Could not load file or assembly

ERROR: Could not load file or assembly XYZ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Seeing this while importing a model in a new environment may mean that the AxUtil.exe.config file is missing.  It needs to be in the same Bin folder as AxUtil.exe and should have the following: <?xml version="1.0" encoding="utf-8" ?> <configuration>  <startup useLegacyV2RuntimeActivationPolicy="true">    <supportedRuntime version="v4.0.30319" /> <supportedRuntime version="v3.5" /> <supportedRuntime version="v2.0.50727"/>  </startup> </configuration>

X++ to read data from a spreadsheet

Often there are times when data needs to be ready from a spreadsheet.  An easy way to handle this is to copy/paste from the spreadsheet to a text file (which will be tab delimited by default) and then use this code (modified as needed) to read that data and do whatever is needed with it.  It includes a dialog to select the file, if the file has a header row, and a progress bar displayed to the user. static void importScriptTemplate(Args _args) {     #File     TextIo                  io;     container               c;     FileIOPermission        permission;     Filename                filename;     Dialog                  dialog;     DialogField             filenameField; ...

SSRS report - column headers on each page

When you have an SSRS report and it's a table where there is a lot of data and you want to see the column headers on each page, the way to do this is as follows.  Highlight the table in visual studio, and below where it shows column groups to the right of that there is a drop down.  Use this to select advanced mode.  Then back to the left, select the top-most Static group - this should be the row with all of your labels.  On the far right, make sure the option RepeatOnNewPage is True.

Split a production order with X++

Below is code for splitting a production order in a Scheduled status based on an input quantity from a dialog.  Note that if this code is put in a class, that class must be set to run on the server, as the AX split code is run on the server.  Note that the status decrease is run twice to get the status to Created, and then the Estimation and Scheduling is run for both the old and new production orders. public void run() {     ProdParmStatusDecrease  prodParmStatusDecrease;     ProdUpdStatusDecrease   prodUpdStatusDecrease;     ProdTable               splitProdTable;     ProdUpdCostEstimation   costEstimation;     ProdParmRelease         prodParmRelease;     ProdUpdScheduling       scheduling;     ProdParmScheduling      prodParmScheduling;     ProdParmSplit  ...

Posting Purchase Order Invoices via X++

In the scenario where you need to post purchase order invoices on a per packing slip basis, you will want to make use of the VendInvoiceInfo series of tables: VendInvoiceInfoTable, VendInvoiceInfoSubTable, VendInvoiceInfoLine, and VendInvoiceInfoSubLine.  A few notes about using these tables from code.  Since there will be no form front end, you won't specify a ParmID in your code.  Also there can only be one invoice line per PO line in each invoice, so if you have multiple receipts to invoice for one PO line, each different packing slip goes in the subLine table.  Also, if you need to use charge codes to apply to the invoice, MarkupTrans table and MarkupAllocation class are your tools.  Below are some code snippets to refer to - they are not intended to be copy/pasted and that's it.  They are just some examples of initializing the tables.  in the code below, psJour is VendPackingSlipJour and psTrans is VendPackingSlipTrans.  You will use class Pu...

Reading XML using X++

In X++ there are some tools available to read an incoming XML file and do some work with it.  XMLNode, XMLNodeList, and XMLElement are the main ones.  An example below shows using a for loop to move through tags under a root.  You can then nest for loops in order to go through more complex XML files. nodeRoot = _xmlDoc.getNamedElement('ROOT'); nodeList = nodeRoot.childNodes();         for (i=0; i < nodeList.length(); i++)         {             node = nodeList.item(i);             switch(node.name())             {                 case 'NODE1':                       //Insert your code here                       break;                 case 'NODE2...

Using X++ to get a list of files in a directory

If you have the need to read a specific directory to get a list of files from it, the following code uses System.IO objects which will work in batch if needed. static container findMatchingFiles(         str _folderPath,         str _filePattern   = '*.*') {     System.IO.DirectoryInfo     directory;     System.IO.FileInfo[]        files;     System.IO.FileInfo          file;     InteropPermission           permission;     str                         fileName;     counter                     filesCount;     counter                     loop;     container        ...