Button Script to open Sales Order UI with parameter.

SOLVED

Hello, 

I have been struggling to get this to work for quite some time and am starting to go crazy! I have created a button on the Invoice History Inquiry which opens up the Sales Order UI, but I want to pass through a parameter so that the Sales Order task opens up with an already populated panel. Below is my current working code that just opens the task:

oSOEnt = 0
oSOEnt = oSession.GetObject("SO_SalesOrder_UI")

if oSOEnt <> 0 then
Set oSOEnt = oSession.AsObject(oSOEnt)
retVal = oSOEnt.Process()
End if

Here is what I have tried in order to open the task with the sales order number populated:

'Attempt 1

oEntry = 0
oSOEnt = 0

oSOEnt = oSession.GetObject("SO_SalesOrder_UI")
oEntry = oSession.GetObject("SalesOrderNo$")

if oSOEnt <> 0 then
Set oSOEnt = oSession.AsObject(oSOEnt)
retVal = oSOEnt.Process('oEntry')
End if

'Attempt 2

entry = 0
oSOEnt = 0

oSOEnt = oSession.GetObject("SO_SalesOrder_UI")
retVal = oBusObj.GetValue("SalesOrderNo$", entry)

if oSOEnt <> 0 then
Set oSOEnt = oSession.AsObject(oSOEnt)
retVal = oSOEnt.Process('entry')
End if

I have tried with all variations of quotation marks (Double, Single, None) and just can't seem to get it right. Any help would be greatly appreciated!

  • 0

    Well for one thing if the invoice is in Invoice History the sales order is no longer in Sales Order Entry. You should be trying to open the Sales order History.

  • 0 in reply to BigLouie

    Good point and with that, you were close with your 2nd attempt.

    entry = 0
    oSOEnt = 0

    oSOEnt = oSession.GetObject("SO_SalesOrderHistoryInquiry_UI")
    retVal = oBusObj.GetValue("SalesOrderNo$", entry)

    if oSOEnt <> 0 then
    Set oSOEnt = oSession.AsObject(oSOEnt)
    retVal = oSOEnt.Process(entry) ' No quotes, just use the variable with value
    End if

  • +1 in reply to jepritch
    verified answer

    Thanks for the reply jepritch. Your above code does not give any errors, but does not populate the sales order history panel. Glad you caught the change to history inquiry! Below is my working script after your and Biglouies input:

    oSOEnt = 0
    theInput = ""

    oSOEnt = oSession.GetObject("SO_SalesOrderHistoryInquiry_UI")
    retVal = oBusObj.GetValue("SalesOrderNo$",theInput)
    theInput = Cstr(theInput)

    if oSOEnt <> 0 then
    Set oSOEnt = oSession.AsObject(oSOEnt)
    retVal = oSOEnt.Process(theInput)
    End if

  • 0 in reply to Surya IT

    That was in our test environment, now in our production environment I use the exact same code and get an error stating "Object required: 'oSession'  Any thoughts??

  • 0 in reply to Surya IT

    Set the button script to run on the server.

  • 0 in reply to Surya IT
    SUGGESTED

    I know this post is really old, but Sage customization information is pretty hard to come by here so I figured I could share the knowledge I have in the event this could help someone else...

    First of all, I should mention the below method requires the use of DFDM, which can break things if used incorrectly. At a minimum, I would recommend creating a backup of the panel you're about to modify. But doing this in a test environment first then migrating to a freshly backed-up production environment would be ideal.

    1. Open up the panel in the customizer (in this case it'd be InvoiceHistoryInquiry)
    2. Determine whether you want to create an actual button or if you want to convert the existing "Order No." text to be a link (similar to other links that opens UI)
      1. If creating a new button: Create a TEXT OBJECT (not a button object) anywhere you'd like the button to go.
        1. We will later be using DFDM to convert this to a button object, but I've encountered issues when starting with a "BT_LINK" object because it has hidden links elsewhere in the panel that can break the entire panel from loading when modified.
        2. In the text object I like to type a long string of "XXXXXX..." to make the object slightly easier to find in DFDM, but this isn't required.
      2. If converting the text object to a link, you don't need to create anything here and proceed to step 3.
    3. Make note of the panel you're modifying in the customizer menu (User/Company) section
    4. Save the panel (even if you didn't make changes, this ensures that a customized panel exists that will be accessible in DFDM)
      1. If you haven't already, this is your last chance to back up your panel before tweaking it with DFDM
    5. Open DFDM ( Library Master > Utilities > Data File Display and Maintenance )
    6. Open the panel in DFDM
      1. ..\MAS90\AR\Custom\<PanelFolder>\AR_InvoiceHistoryInquiry.M4L
        1. Where <PanelFolder> is the "user/company" combination you determined from step # 3
          1. If the user and/or company was "ALL", then it will be listed as ###
    7. Locate the text object you are going to modify by clicking the magnifying glass and searching for the panel the object is on. For existing text conversion, it will be in DMAIN -> FT_ORDERNO.
    8. Change the following properties by clicking Edit:

    This is # 24 so you're not having to type it in: UI=SO_SalesOrderHistoryInquiry_ui;FIELD=SalesOrderNo$

    Now property #21 can have various values here. This will ultimately change the appearance of your button, so much so that it might not look like a button. If you decided to go with the converting the sales order text method, you might want it to look more like a link and not a button at all (just like the other links to UI appear). So here are a few settings I've come across:

    Property #21 (Nomads_Sts$) and their values/appearances: Case matters! (upper/lower)case
    Note: All property values here are UPPER-Case with the exception of the second-to-last ('f')

    •  Generic Appearance (no modifications)
    • F - Removes the button's border, but still adds a hover border
      • Without Mouse hover:
      • with hover:
    • S - doesn't keep focus when clicked. If not used, will retain focus: 
    • V - Gives it a blue "link" color and changes the mouse pointer to a hand finger when hovering (the example is being used w/ 'F' to help show, but would have a border w/o 'F')
    • U - As would be expected, underlines the text (had to change obj height to 1.25 minimum to show)
      • without 'F': 
      • with 'F': 
      • with 'FV': 
    • f - removes the 'hover' border
    • T - Square border (not sure how much this affects borderless-"links", but I use it anyways)
           Edit: 07/28/2023 - Turns out after messing around another custom button that I was wrong what this attribute was for, although when used by itself (as you can see below) it visually does look square.
      Anyways, this attribute actually means "Transparent" (which makes more sense given what code they used). I could see this being useful as an overlay to another control object (especially when combined with F to remove the border).

    Then you can also add other normal properties here as well, D = Disabled, L = Locked, H = Hidden, etc.

    You can mix/match any combination of these properties. I use FSVUfT<D (D - Disabled, but since it's part of the Hyperlinkpush/customer group, once you enter an invoice number this group combination re-enables our object (so users aren't clicking a link without a sales order).

    This is the final result for what I use:   . It will open up the order history inquiry UI and more importantly, it uses the order number that is associated with the invoice inquiry lookup.

    This is obviously a bit complicated, I know. But this isn't really supported by Sage and is more of a 'hack' then anything, but I've used this for a while now and have not had any issues.