hi i am using navision attain 310. when ever we use the ERROR function in a codeunit, the process is terminated whenever there is an error. Can we catch the error and store it some where and can see at a later stage why the process was teminated. This will be useful in batch posting like that of sales order. with regards Harikesh
The error function you are using is specifically called by code. It doesn’t actually trap an error, it is only used to error out of code when you’ve performed checks and determined you cannot proceed (as a developer). Try making your text messages in the ERROR window more descriptive to evaluate where your problems are occuring. What you are talking about for trapping errors in Navision would be an “error object” that could be called. Navision doesn’t have an error object that can be trapped. Your only method available to see errors as they occur is to use the Debugger, which is cumbersome at best in v3.10.
Sure you can trap your error, only we don’t call it trapping a error. In stead of just calling your codeunit call it in a IF statement.
IF NOT Codeunit.RUN THEN ERROR(Text0001); Good luck!
HI Emiel Romein IF NOT Codeunit.RUN THEN ERROR(Text0001); You are very correct, but Text0001 will not give the error why the posting or the porcessing stopped. Regards Harikesh
Harikesh, I think in Emiels example Text001 is a text contstant the would say something like ‘process failed’ or something like that. If you wanted to get some more detil about what went wrong in the codeunit you would need to extend the parameter list if the codeunit you call. Add a Text parameter passed by reference (VAR = TRUE) in addition a boolean return value so the codeunit would look like… BatchProcessCodeunit(VAR ErrorMessage:Text) : Boolean Anywhere in your batchprocess codeunit you trap an error you do… if whatevererror the begin ErrorMessage := ‘Whatever description’; EXIT(FALSE); end else … carry on processing In the code where you call the batch process codeunit you do something like… IF NOT BatchProcessCodeunit(LtxtErrorMessage) then ERROR(LtxtErrorMessage) you could also of course write the error message to a log file, which is what you would normally do in a batch process. I hope this helps. Chris.
thanks chris, i liked ur solution and will try a hand on it. regards hari