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

    Anybody?  Sage refuses to help me figure this out, is there really nobody out there that has any ideas why this module doesn't work like every other module?  It was working perfectly in version 2021 with Scanco's production management but now that Sage took it over they seemed to have stripped it down to an unusable state.  And yes, I've already wasted the $99 on the BOI class which is broken at the moment and repeats the introduction video as the third video where most of the 'meat' is about BOI.  I would certainly appreciate any guidance.

  • +1 in reply to justinp
    verified answer

    Try changing this line:

    $r = $o->oLines->nSetValue('WorkTicketNo$', $workTicketNo);

    To:

    $r = $o->oLines->nSetValue('WorkTicketKey$', $workTicketNo, 'kWORKTICKETNO');

  • 0 in reply to Steve Passmore

    Thank you for that, but unfortunately it still gives me the exact same message.  I don't know if there's something missing before the addLine() call that is missing?  Not sure what the return value of 2 is, I don't see a 2 anywhere in the documentation.

  • 0 in reply to justinp

    a return value of 2 on the AddLine() means a new record has been created.

  • 0 in reply to Steve Passmore

    Ok, thanks for clarifying that.  So, any ideas from here?  I can't seem to understand why adding a line to a transaction is giving an error that the transaction number is invalid.  I double checked before the addLine() with nGetValue() to verify and it does show the correct transaction number so I know it's correct.  Is there possible a method that I'm missing before the addLine() that needs to be called first?

  • 0 in reply to justinp

    I did a test using the business objects doing the same method calls that you are using and mine worked.  I successfully created a transaction entry for a work ticket completion.

    Looking at your original post, the only thing that seems odd is the return value on the header SetKey() returning a 1.  That would indicate that an entry with that TransactionNo$ already exists.  I would expect a return value of 2 for a new record.

    After getting the failure on the SetValue() of WorkTicketKey$ in the Lines are you retrieving the LastErrorMsg$ from the header or the lines object?  You would need to be using the lines object to see what the failure of that SetValue() is.

    The difference between Pre-2022 Production Management and 2022 is there is now a surrogate key on the work ticket header, WorkTicketKey$.  That is why I suggested using the extra argument in the SetValue() to specify the secondary key for WorkTicketNo$.  That forces the validation logic to use that secondary key when doing the validation of the value passed in.  This would work similarly to how you would set a G/L account field using the fully formatted account value.

  • 0 in reply to Steve Passmore

    I was getting the LastErrorMsg from the header, I changed it to get the lines objects LastErrorMsg and now the response from the WorkTicketKey line you provided is showing:

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

     

    That is the correct work ticket number (not key, the work ticket key for that work ticket number is 000000000038). 

    Should I be using the WorkTicketKey and not the WorkTicketNo?

  • 0 in reply to justinp

    Yes, WorkTicketKey not WorkTicketNo.

    You just need to pass the first argument in the SetValue() as WorkTicketKey, the second argument is the work ticket number you want to set and the third argument has to be kWORKTICKETNO.

  • 0 in reply to Steve Passmore

    Okay, so the first thing I'm doing after the addLine() is:

    $r = $o->oLines->nSetValue('WorkTicketKey$', $workTicketNo, 'kWORKTICKETNO');

    And the response I"m getting is:

    SetValue (WorkTicketKey): 0
    o->oLines->LastErrorMsg: 000000108325 is not on file.
  • 0 in reply to justinp

    I'm out of suggestions unfortunately.  The SetValue() for WorkTicketKey using a WorkTicketNo value had worked for me when I tried it.

    The snip of DFDM above shows my PM_WorkTicketHeader record.

    I had done SetValue( "WorkTicketKey$", "000000095056", "kWORKTICKETNO") which succeeded.  Checking the field WorkTicketKey$ in the lines showed that the value was set to "000000095031".