Scripting

  • 1.  It's me...again. This newest client of mine is rea

    Posted 10-30-2017 20:35
    It's me...again. This newest client of mine is really giving me some good practice time. Now they want me to capture a date/time stamp when the Picking Sheet is quick-printed in Sales Order Entry. The script works to set the UDF value when I use and Table Post-Read event and the SO Options are set to re-display the source document. But if I turn that SO Option off, I can't get the script to work with any of the Read/Write/Validate events. Does anyone have an idea on the event that should work in this case, or maybe there's a way to track a user's interaction with the ""Print Pick"" button? Thanks in advance!


  • 2.  RE: It's me...again. This newest client of mine is rea

    Posted 10-30-2017 21:28
    You could try hiding the original BT_QPPicking button on the DMAIN and DMAINW panels, put in its place a replica script button set to run on the server. You don't need an event script. Try the following code in the button script. You will need to replace sDateTimeStampValue with your value/variable and UDF_FieldName with your field name. --------------------------------------- nRetVal = 0 sSalesOrderNo = """" nRetVal = oBusObj.GetValue(""SalesOrderNo$"", sSalesOrderNo) nRetval = oUIObj.BT_QPPicking() 'If you look in the resources at SO_SalesOrderUI (or any UI object for that matter), you will see methods that share the same name as certain buttons on the panel, these can be called like this line vs using oScript.InvokeButton, This method also makes sure the methods are triggered in the order they appear in the script. If nRetval = 1 Then ' The below section is just illustrating how you can get module options and choose a different route in your code accordingly, you could shorten this with a GetValue on the sales order number field into a different variable, if you get a blank value back, then the source was not redisplayed. sRedisplayAllDocuments = """" nRetVal = oSession.GetParameter(""S/O"", ""RedisplayAllDocuments$"", sRedisplayAllDocuments) sRedisplayPickingSheets = """" nRetVal = oSession.GetParameter(""S/O"", ""RedisplayPickingSheets$"", sRedisplayPickingSheets) If sRedisplayAllDocuments = ""Y"" Or sRedisplayPickingSheets = ""Y"" Then nRetVal = oBusObj.SetValue(""UDF_FieldName$"", sDateTimeStampValue) nRetval = oUIObj.BT_Accept() nRetval = oUIObj.InvokeChange(""SalesOrderNo$"", sSalesOrderNo) Else nRetval = oUIObj.InvokeChange(""SalesOrderNo$"", sSalesOrderNo) nRetVal = oBusObj.SetValue(""UDF_FieldName$"", sDateTimeStampValue) nRetval = oUIObj.BT_Accept() End If End If --------------------------------------- This has drawbacks as you can't be certain the picking sheet was printed without using additional replica buttons on the quick print screen and setting some storage variables but even then, you are not guaranteed the print job completed successfully. You also would need to work in additional logic for handling if the quick print picking sheet is triggered after printing the sales order. This should give you a start though.


  • 3.  RE: It's me...again. This newest client of mine is rea

    Posted 10-31-2017 16:22
    What he said. ^^^^^


  • 4.  RE: It's me...again. This newest client of mine is rea

    Posted 10-31-2017 18:39
    Thank you so much, David. I figured there would be a suggestion to create a custom button, but I had never done that before and now can see how to. I appreciate the help!