BOI Create Completion Transaction for Work Ticket

SOLVED

I'm trying to use Business Objects to create a completion transaction for a Work Ticket in Sage 100 2022.  I can't seem to figure out how to add the work ticket to the actual transaction.  Below is a slimmed down version at its simplest form of what I'm trying to do.

$r = $this->oSS->nSetProgram($this->oSS->nLookupTask("PM_Transaction_UI"));
$o = $this->oPVX->NewObject("PM_Transaction_bus", $this->oSS);

$transactionNo = new \VARIANT("");
$r = $o->nGetNextTransactionNo($transactionNo);
// $transactionNo returns "0240859" (Different every time)
// $r returns 1

$r = $o->nSetKeyValue('TransactionNo$', $transactionNo);
$r = $o->nSetKey();
// both $r's return a 1

$r = $o->nSetValue('TransactionType$', $transactionType);
// $r returns a 1

$r = $o->oLines->nAddLine();
// $r returns a 2 (No clue what a 2 means)

$r = $o->oLines->nSetValue('WorkTicketNo$', $workTicketNo);
// $r returns a 0
// LastErrorMsg gives me "The 0240859 is invalid."

$r = $o->oLines->nWrite();
// $r returns a 0

$r = $o->nWrite();
// $r returns a 0
// Last ErrorMsgs gives me "You must enter at least one line."

$this->oSS->DropObject();
$this->oSS = null;

Any ideas what I'm missing here?  Should I not be using the oLines object like I do pretty much everywhere else?  This in in PHP but hopefully the logic is sound.

  • 0 in reply to Steve Passmore

    This is very odd indeed.  Mine also shows the correct record in DFDM as well.

    Are there possibly any configuration options somewhere I'm missing that would prevent that?  I am able to create work tickets without issue, as well as sales orders and invoices.  I just can't seem to get this transaction working.

  • 0 in reply to justinp

    None that I know of.

    Just as an experiment, since in this example you know the WorkTicketKey value, try doing a SetValue( "WorkTicketKey$", "000000000038" ) to see if that succeeds.

  • 0 in reply to Steve Passmore

    Nice thought, but similar issue.

    AddLine: 2
    SetValue (WorkTicketKey): 0
    o->oLines->LastErrorMsg: 000000000038 is not on file.

  • 0 in reply to justinp

    Do you have batches enabled?  That's caught me a couple times.

  • 0 in reply to Kevin M

    I did not have batches enabled, and thought that may have been the problem so I tried enabling them this morning but found the batch options were missing from the Production Management Options area.  I had to have Sage Support fix that for me in order to enable them, and after trying them I didn't get any further so I disabled them once again.  They've been disabled throughout this testing with you today.

  • 0 in reply to justinp

    Status on the WT is released?

  • 0 in reply to justinp

    Steve's suggestion works for me.  Are you running your script for a different company which has different work tickets (ie. not TC1)?  I make this mistake sometimes.

    How can the batch options be missing?  They should be on the PM Options - Entry tab.  What does your Entry tab look like?

  • 0 in reply to Kevin M

    Yes, the WT is released.

  • 0 in reply to Natasha Chang

    I'm beginning to think something went wrong with the installation because the batches were missing (the were manually added in from Sage support), and there was another problem with activating the Production Management module in the beginning that support had to fix.  They said something with the original Wok Order Module didn't remove itself like it should have.  I'm going to try and reinstall Sage from scratch today (this is a test server at this point anyway) and see if I can get any further on this.  I didn't think there was anything wrong with the code and I've been pulling my hair out about it.  I will update after the reinstall later and see if that worked.

  • 0 in reply to Steve Passmore

    So I finally had time to completely re-install Sage 2022 from scratch.  All the missing options like batching are there and everything is working perfectly in the App itself.  However, I'm still getting the exact same error message any time I try to add a line record.  It is doing it on Work Tickets, Work Ticket Transactions and Sales Orders alike.  I tried a very simple script to create a Sales Order with a single item on a line and I get the same error message as before with Work Ticket Transactions.

    $r = $o->oLines->nAddLine();  // Returns a 2
    $r = $o->oLines->nSetValue('ItemCode$', $itemCode); // Returns a 0
    o->LastErrorMsg: The 0226560 is invalid.


    I cannot for the life of me figure out what is going on. Is there some setting, or permission that is preventing me from doing this simple task in 2022? I'm using the SO_SalesOrder_bus object, do I need to switch to another business object to handle lines now instead of just using the oLines method?