JobOps WT Template Modification Through BOI

SOLVED

Hey everyone!

I'm attempting to modify and create/remove work ticket templates via BOI (through C# and Entity Framework) and I'm not having much luck.  I'm not sure what object the template table is a part of and I haven't been able to find anything specific to updating templates on the web or here.

For reference I'm working in Sage 100c Premium 2018 (6.00.10.0) and here is a snipped of the code:

Any help would be greatly appreciated!

  • +1
    verified answer

    Well, since JobOps isn't written by sage, you're not going to find any documentation on its classes and tables like the standard sage 100 resources.

    It has been a while since i have worked on a JobOps system but here are a few things.

    The StartProgram used when launching Work Ticket Template Maintenance from the menu is "JT_Template_UI".  This is the same class you would use if you wanted to get an object handle to the UI object and call its Process method to launch the UI for the user.

    The *_Bus class name used by the UI task above is "JT_Template_Bus".

    The key fields for the *_Bus class are TemplateNo$, RevisionNo$, and WTStep$.

  • 0 in reply to David Speck

    Hey Daivd! Thank you so much for your help - that did the trick!

  • 0 in reply to David Speck

    One last question for you David - I'm trying to remove a line from the template and the code below returns "Missing or invalid header"

    Any ideas on what I'm doing wrong?

  • 0 in reply to js-goose

    i don't think i have ever used the DeleteLine method but instead, the Lines object's Delete method.

    Regardless, there is no need to call the Lines object's Write method after deleting a line.  This might be causing the false positive message about the missing or invalid header.  If you have to narrow down a specific line that is setting the LastErrorMsg property, you need to set it to a blank string before calling the method you intend to test.  In VBScript, this is done like this, tLines.sLastErrorMsg = "".

    The only other thing i can think of that might cause the missing or invalid header message is if the SetKey method alone is not sufficient to set up the detail object.  If this is the case, after checking that the SetKey does not return 0, call the header object's SetCurrentKey method, you can pass it the value returned from the header object's GetKeyPadded method, if this fails, try just GetKey.

  • 0 in reply to David Speck

    Hi David, I took your comments and adapted them to my code and was able to remove a line in the template with the following:

    Thank you - you've been immensely helpful in this process.  I feel like I'm cooking without the recipe here haha

    I do have another question if you would be so kind - Now I'm looking to create a Template header item in JT_Template.  I tried adapting the SO creation code from a SAGE course I took but that hasn't yielded results like I expected.  Here is my code:

    I thought since that template number is not on file it would create it but my check after the key value field sets returns "Error Setting CREATE HEADER Item: TESTFROMAPI is not on file" which says to me that it's searching for that template number as opposed to creating it.

    Any help is greatly appreciated and I owe you a drink for everything you've helped me with!

  • 0 in reply to js-goose

    Regarding creating a new template, you need to keep a couple things in mind.

    1. SetKey can return the following;
      1. -1 (warning, such as a sales order being invoiced or a sales order that is already opened by another user). 
      2. 0 (failure). 
      3. 1 (record already exists).
      4. 2 (new record).
    2. Your else statement has "Error Setting CREATE HEADER Item" hardcoded when the returned value from the SetKey is not equal to 1.  This is part of your problem, it could be returning a 2 but you wouldn't know it with your current code.  Whenever you are evaluating the returned values, you should include both the returned value and the object's LastErrorMsg property.  If you suspect that an earlier method of the object set the LastErrorMsg property, you can set the LastErrorMsg property to a blank string before calling the method that you need to trap.  LastErrorMsg can contain both warnings and errors so you have to handle it appropriately.
  • 0 in reply to David Speck

    You were right on the money with the way I had the return values hard coded being one of the issues.  It was returning 2 but I wasn't capturing that.

    Thank you again David you have been a life saver and I owe you!