# [ ax2012 ] Removal of suspension of recId allocation for table VendInvoiceInfoTable has failed

Problem

When press PO invoice button, there is an error.

Therefore, I try to delete invoice in AP > invoices > pending invoices

(ref : http://axaptaexplorer.blogspot.com/2013/04/how-to-delete-pending-invoices.html , Thanks very much for short and effective blog )

In my case, TransDate was missing from the Network down. Therefore, the exchange rate cannot be get for the (blank) date

Therefore, I put TransDate and then go to remove as normal case AP > invoices > pending invoices

# [ ax2012 ] Unit Cost calculation

We guessed this is the formula for the moving average price in

– Inventory and warehouse management > Periodic > Closing and adjustment

– Adjustment > Revaluation for moving average

Unit Cost = (Posted value+Edit now)/Posted Quantity

# [ ax2012 ] cancel Delivery Order

Error

Cannot edit a record in Sales order - update table (SalesParmTable).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.

This is because Ax throws the exception in /Classes/FormletterService/method/run

Exception::UpdateConflict

and the system have a code between try and setPrefix to retry again within the #RetryNum times.


try
{
...

setPrefix(this.prefixParmTable(formletterParmTable));

before throws Exception::UpdateConflict.

Real error

If we commented out the Exception::UpdateConflict block, we will see the real exception in \Classes\InventModelType_MovingAverage\checkInventOnHand

The inventory value of 102,476.71 is not expected after the proportional expense calculation. The expected value is 85,397.25.

Reason

It is because of the Ax getExpectedCost from cache ( InventModelType_MovingAverage.getExpectedCost(inventSum) ).
The cache was set in the cancel process in /Classes/InventModelType_MovingAverage/setExpectedCost.

When we post cancel delivery in \Classes\InventModelType_MovingAverage\setExpectedCost. If _inventTrans.DatePhysical >= systemDateGet(), then the expected cost will be set. This _inventSum.PhysicalValue is not include the price of the item in this DO.

After that, /Classes/InventModelType_MovingAverage/getExpectedCost will get from cache. Because the _inventSum.PhysicalValue that we set earlier did not include the price of the item in this DO, the validation is fail.

However, if it is ( _inventTrans.DatePhysical < systemDateGet() ), the cache is not set.

Therefore, the /Classes/InventModelType_MovingAverage/getExpectedCost get another _inventSum.PhysicalValue that include the price of item in this DO, so the validation is passed.

# [ ax2012 ] SO charge code

– charge code is for the whole invoice

– register charge code in SO, then invoice, after that the charge code is post to that invoice and charge code in SO is disappeared.

– when we issue another invoice, we have to enter the charge code again.

– to keep the charge code, tick Keep in Charges form

# [ ax2012 ] calling Ax32.exe instead of AxHLink.exe

Since AxHLink.exe will limit to only the default configuration, we will call the Ax32.exe that is more open to various configuration instead.

To do that,

AxHLink.exe Dynamics://0?DrillDown_5637192587

we use startupCmd parameter of Ax32.exe

&quot;C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32&quot; &quot;C:\path\to\configuration.axc&quot; -startUpCmd=DrillDown_5637192587

Note that we can find multiple feature of startUpCmd under Switch section of the following class ( as explained in MS ref )

\Classes\SysStartupCmd\Construct

Note2 : allow all arguments to pass from the client is risky, so it is better to call to .bat or .lnk instead of calling directly to ax32.exe

# [ ax2012 ] called by Csharp

using System;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApplication1
{
/// &amp;lt;summary&amp;gt;
/// Interaction logic for MainWindow.xaml
/// &amp;lt;/summary&amp;gt;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void button1_Click(object sender, RoutedEventArgs e)
{
// System.Diagnostics.Process process = new System.Diagnostics.Process();
// System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
// startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
// startInfo.FileName = &amp;quot;cmd.exe&amp;quot;;
// startInfo.Arguments = &amp;quot;C:/Program Files (x86)/Microsoft Dynamics AX/60/Client/Bin/Ax32.exe&amp;quot;;
// process.StartInfo = startInfo;
// process.Start();

string str = @&amp;quot;C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe&amp;quot;;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = str;
process.StartInfo.Arguments = @&amp;quot;-startupcmd=AutoRun_C:\csharp_prototype\XMLFile1.xml&amp;quot;;
process.Start();

}

private void button2_Click(object sender, RoutedEventArgs e)
{
string str = @&amp;quot;C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe&amp;quot;;
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = str;
process.StartInfo.Arguments = @&amp;quot;-startupcmd=AutoRun_C:\csharp_prototype\XMLFile2.xml&amp;quot;;
process.Start();
}
}
}
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;

&amp;lt;AxaptaAutoRun logFile=&amp;quot;\$HOME\axEXProd.log&amp;quot; version=&amp;quot;4.0&amp;quot; exitWhenDone=&amp;quot;false&amp;quot;&amp;gt;

&amp;lt;/AxaptaAutoRun&amp;gt;