BOI SO_SalesOrder_bus call to nSetKey(key) fails, sLastErrorMessage = "This order is currently being shipped. The invoice number is [num] in batch [num]"


Using the BOI and trying to loop through all Sales Orders and, for each Sales Order, loop through all lines. Have it working however some orders are in a state such that, if opened from the Sage UI, a popup is shown with text like:

In the UI, I can click "OK" and proceed to view the record.

From BOI I can access the SO_SalesOrder_bus object (using nFind() call) however I then need to call nSetKey to access the order lines. When call:

int nSetKey = busObject.nSetKey(busObject.sGetKey());
A result of 0 is returned, with sLastErrorMsg = "This order is currently being shipped. The invoice number is [num] in batch [num]"
So, my question is, how can I read all the lines from this order whilst it is in the "being shipped" state? I do not need to update the lines, just read them. For example, can I apply some sort of setting to the session "no messages"/"non-interactive", or should I collect the lines a different way?
  • +1
    verified answer

    If you are only reading data, try the service object.  I don't believe the Lines object is pre-filtered to the correct SO that way, but a browse filter can probably help do that.

  • 0 in reply to Kevin M

    Thanks, will try that.

  • 0 in reply to Kevin M

    Thanks for the suggestion Kevin, I adjusted to call nSetBrowseFilter on the lines instead of calling nSetKey on the business object and am no longer getting the error. Decided not to switch to the SO service object (for now) as I noticed that the SO service object does not provide direct access to the lines (i.e. the related oLines field is not present on the service object) -- so, I would need to create another COM object read the lines etc ...

    var comLinesObject = comObject.oLines;
    int nSetBrowseFilterForLines = comLinesObject.nSetBrowseFilter(comObject.sGetKey());