Scripting

Expand all | Collapse all

OK, here's the scenario. Sales Order Entry - I wa

  • 1.  OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-03-2016 14:22
    OK, here's the scenario. Sales Order Entry - I want to take the user entered information in the Item code(probably a misc code) , do some gyrations based on what they selected and replace it with a new item code, I was then hoping that the ""is this a new inventory item"" question would fire but it fails because my new item code isn't on file. I can't believe i haven't run into this in the past...any creative ideas or obvious fixes that i'm unaware of?? Thanks !


  • 2.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-03-2016 14:44
    I'm confused. You said you were: ""hoping the 'is this a new inventory item' question would fire but it fails because my new item code isn't on file."" Maybe I don't understand what you mean by ""fails"". Isn't it expected that the question would fire **_because_** the new item code isn't on file?


  • 3.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-03-2016 14:50
    I think he means that instead of popping up the ""Is this is new inventory item"", which is what he wants, it's just failing in the script, which doesn't allow the item to be added. @BrettLyder, your script is manipulating the business object, probably using a Setvalue(). The prompt ""Is this a new inventory item"" comes from the UI object which is responsible for calling the ""On the fly"" Item Maintenance task. The business object doesn't know how to call a UI task to allow entry, so it just returns an error message. You could trap the error message then prompt within your script to add a new one, then instantiate and process the Item Maintenance UI, but that's probably pretty complicated. I hope someone else can come up with a more elegant solution for you. - Phil


  • 4.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-03-2016 14:54
    Yes Phil, that is what I mean. I did wonder about instantiating Item entry.


  • 5.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-03-2016 14:58
    It could certainly be done, Brett, and it might not be as complicated as I was thinking. It is possible to instantiate a UI object and use the o.process() method from within the script. If you specify the appropriate screen and pass in the new item code, it might work just fine. I'll just bet someone out there has already done something like this, but I have not.


  • 6.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 07:05
    I'm with @PhilipWhirley, if you use an oUIObj.InvokeChange instead of SetValue, it might behave as you expect. The other thought I had was to add the new items via script and then remove the Misc Codes at that time or maybe during the table write.


  • 7.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 07:15
    Thanks Steve, I'll try the invokeChange. Do you have happen to know the syntax for it?


  • 8.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 07:25
    Never mind, I found it.


  • 9.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 07:47
    Holy Cow, InvokeChange worked @SteveIwanowski !! It didn't actually show the new item code in Sales Order until it came back from Item Maintenance but so what. Thanks again!


  • 10.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 07:58
    For @RobertWood : Here's the syntax i was missing before: Set myUIObj = oSession.AsObject(oScript.UIObj) retval = myUIObj.InvokeChange(""ItemCode$"", ""New Item Code"", ""GD_Lines"") FYI: You do need to make sure you're in the UI for it to work.


  • 11.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 08:47
    Brett some addl notes for you: * Use InvokeChange() when you want to ""just write to the screen"". There is also another way to bypass validation that may have worked for you. If you wanted for example your script to fire off during a V/I import where there is no UI, then InvokeChange() won't work you have to do it other way. * Setting a handle to oScript.UIObj is necessary on event scripts but not button scripts. Here's what I usually do: 'Are we running from a button script? isButtonScript = IsObject(oUIObj) If isButtonScript = False Then Set oUIObj = oSession.AsObject(oScript.UIObj) End If 'Now run in any UIObj commands like InvokeChange() This checking can be extended further if running a UI Script in v2015+ * The 1st arg is the name of the control on the screen which is not always same as the name of the field in dictionary (what you see in File Layouts). If you're not working with a grid you can do Ctrl-F9 / Customizer Selection to get the control name. * Omit the 3rd arg if you're not on a grid, obviously.


  • 12.  RE: OK, here's the scenario. Sales Order Entry - I wa

    Posted 02-04-2016 08:54
    Yep, thanks Alnoor. I always appreciate your input!