Programmatically posting a Sales Order

rjsfrjsf Member Posts: 17
I have a client that requires a customization to automatically post sales orders on a schedule.
The automated posting is scheduled at night, and the client would want to know in the morning of the next day through a log file what sales orders posted successfully and what did not and what the error message was.
I have figured out the automation part and am calling the sales-post codeunit.
However, the sales-post codeunit aborts when it finds an error and outputs a dialog box.
Is there a way through code to silently post multiple sales orders one by one without bogging down on an error but just simply log it and move on to the next sales order? :?

Any input is greatly appreciated. Thanks!

Comments

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Welcome to Mibuso

    Post with Job Queue Option is available in NAV2013. Please check.
  • rjsfrjsf Member Posts: 17
    Hi Mohana, thank you for your suggestion. I haven't yet tried using a job queue to accomplish the task. What I did was a single-instance codeunit with a timer, and this codeunit loops through the sales orders and calls the sales-post codeunit for each. Whenever sales-post encounters a sales order with a problem, it outputs a dialog and breaks the loop. I have only tested this from the object designer but suspect it will also break the loop when run from NAS.

    So are you saying that by calling post through a job queue, this problem will not occur? If I use a job queue, will I be able to capture the error messages and put them into my own custom table? The custom table is a requirement.

    By the way, I am on NAV 2009 R2. Thanks!
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    rjsf wrote:
    By the way, I am on NAV 2009 R2

    Please Upgrade to NAV2013, Post with Job Queue Option is available by default in NAV2013.
  • bbrownbbrown Member Posts: 3,268
    Take a look at the "Batch Post Sales Invoices" process (Report 297). It should provide you some guidance in the area of handling failed orders. You could also use the GETLASTERRORTEXT function to log those errors.
    There are no bugs - only undocumented features.
  • rjsfrjsf Member Posts: 17
    @Mohana: I'm sorry but upgrading at this time is not an option.

    @bbrown: I'll check the report out, thanks!
Sign In or Register to comment.