I want to catch error when convert purchase to packing slip:
dialog = purchformletter.dialog( );
if (dialog.closedOk( ))
I tried to put run method into a try/catch statement with no success. How can I catch if there are errors at run?
Note: This is an AX 2009 case.
There already is a try/catch block in PurchFormLetter.run() that catches (and doesn’t re-throw) exceptions. Implement your logic there.
If I add a return parameter for catch error to run method of purchformletter does that cause any trouble?
Sorry, I don’t understand what you mean. Can you give me an example?
Sorry, my bad english… You know, run method doesn’t return a parameter actually, I just mean’t make run method to becomes return a parameter:
errorOccured = true;
You can’t change the return type because
- PurchFormLetter.run() is defined in SYS layer
- The signature is defined by a parent class (RunBase) and an interface (SysRunable)
Nevertheless you can change the state of the object in run() and call other methods later to read the state. The current logic logs information about errors to PurchParmTable table. If it’s not suitable, write additional information in the catch (Exception::Error) block and expose the data by a new method.
For example, you can add the following method:
public boolean errorOccured()
return purchParmTable.ParmJobStatus = ParmJobStatus::ContainErrors;
thank you, it’ll work for me. I tried to put a parm method to purchformletter but unfortunately got error. I couldn’t understand why…