Scripting

Expand all | Collapse all

Hi all - I need to figure out a way to prompt the

  • 1.  Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:28
    Hi all - I need to figure out a way to prompt the user when a Customer PO field is blank in Sales Order Entry but not require them to fill it in, so I can't use PreWrite...it's just a warning/message. I have tried OnExit from Header tab, PostLoad and PreTotals on Totals tab and various other combinations but nothing is working. I'm assuming it's because the value isn't written to the SO_SalesOrderHeader field so it can't be validated, but I'm sure I'm missing some elementary. Does anyone have any suggestions? Thanks in advance!


  • 2.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:31
    Did you check the script for syntax errors when you had it on the OnExit event of the regular and wide version of the header tab? Are you using SetWarning/SetError or MessageBox? First two only work in ""pre"" events.


  • 3.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:32
    Pre-Write (with a filter for when there is a UI). Pop-up an OK / Cancel prompt. OK, set a checkbox (which upon next execution of the script you set to bypass the validation). Cancel >> SetError... for the user to enter a correction.


  • 4.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:33
    David, there's nothing to the script so it passed syntax check: sOrderType = """" retVal = oBusObj.GetValue(""OrderType$"",sOrderType) If sOrderType <> ""S"" Then Exit Sub End If sCustomerPO = """" retVal = oBusObj.GetValue(""CustomerPO$"",sCustomerPO) If sCustomerPO = """" Then sMsg = ""*** Customer PO # IS BLANK ***"" retVal = oScript.SetError(sMsg) End If


  • 5.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:33
    Amber, If I understand your requirement properly you are simply want to prompt the user if they are trying to save a sales order that doesn't have a customer po typed in. So I would use the table pre-write, i would getvalue the customerpo field, if the field is blank use a oUI.messagebox and display its blank and you could then use ok/cancel or yes/no to continue and if they don't want to continue seterror


  • 6.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:35
    Guess i should have posted a new comment instead of editing my original. I see in your script you are using SetError, this only works in ""pre"" events. Use it in the table pre-write event or use the oSession.AsObject(oSession.UI).MessageBox in the OnExit event.


  • 7.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:40
    also, like @KevinMoyes said, check for the UI if using the table pre-write event.


  • 8.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:44
    I found how to use the MessageBox but I still get the popup even after I've populated the CustomerPO field. I will see if I have any Intro class examples to borrow from on ""checking for the UI"" and the ""OK/Cancel"" prompt, as I've never done that before. Thanks all!


  • 9.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:57
    What event are you using now? In a table script, you can check for the UI using either of the following. -------------------------------------------- if oScript.UIObj > 0 then 'UI is present end if -------------------------------------------- OR -------------------------------------------- if cBool(oScript.UIObj) then 'UI is present end if --------------------------------------------


  • 10.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 09:57
    CustomerPONo is the field name. If oSession.StartProgram <> ""SO_SALESORDER_UI"" Then exit sub End If Or you can check if oSession.UI = 0 'this means that UI is not running Search the help files for MessageBox to see the syntax for options related to buttons.


  • 11.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 10:11
    I feel so stupid. I had the field name wrong this whole time. That's what I get for being cute and hand-typing everything rather than selecting. It does work now whether I use OnExit from Header or PostLoad on Totals. I'm so sorry for wasting your time, guys!


  • 12.  RE: Hi all - I need to figure out a way to prompt the

    Posted 03-09-2018 10:17
    been there before, right up there with forgetting to add the $ for a string field too.