Issue with button script/refresh grid

SUGGESTED

I have a button script in SO entry which uses the new invoke lookup function. The lookup calls the customer's price schedule list then after selecting it Adds that item to the order. The script works fine as long as the line is not the first line. If the line is the first time it forces focus to the totals tab. After the first line is written and you go back it never happens again. Anyone have any ideas???

Here is a copy of the script:

retVal = 0
val = ""
sDiv = ""
sCust = ""
sItem = ""

lookupCode = "IM_PriceCodeCust"

retVal = oBusObj.GetValue("ARDivisionNo$", sDiv)
retVal = oBusObj.GetValue("CustomerNo$", sCust)
set oLines = oBusObj.AsObject(oBusObj.Lines)

If lookupCode <> "" Then

retVal = oUIObj.InvokeLookup(LookupCode, val, sDiv + sCust + String(20 - Len(sCust),chr(0)))


If retVal<>0 And val<>"" Then


sItem = replace(mid(val,6,30),chr(0),"")
retVal = oLines.AddLine()
retVal = oLines.SetValue("ItemCode$", sItem)
retVal = oLines.Write()
oScript.LinesAdded = 1
retVal = oScript.LoadGrid("GD_Lines")
retVal = oUIObj.HandleScriptUI()

End If
End If

  • 0

    Nevermind! I changed the script to InvokeChange() instead of AddLine and it works fine now!

  • 0 in reply to nronchetti

    HI nronchetti,

    Just curious -  is there documentation available for this particular function (InvokeLookup)?  I have pretty old scripting documentation that was provided after taking the BOI class years ago, but it doesn't include this method.  This would come in very handy, but I'm a little unclear on how you determine the proper 'lookupcode' when using the method.  Thanks!

  • 0 in reply to Justin K
    SUGGESTED

    Hi ,

    The InvokeLookup() function was introduced in the Sage 100 ERP 2015 release.  Here is the basic syntax of the function and how to determine the proper 'lookup code'.  Maybe has an alternate way to find the lookup that works better. :)

    InvokeLookup(lookupCode, value, [startValue])

    lookupCode - A valid Sage 100 ERP lookup code

    data       - the value the user selected

    startValue – {optional} if a lookup requires a start value, such as the Customer Contact lookup, optionally include this value.

    example:

    retVal = oUIObj.InvokeLookup(“CI_ItemAll”, item)

    Finding the Lookup Code you want

    • Turn on debugging (same procedure to use oScript.DebugPrint() )
    • Go to location in Sage 100 ERP and start the lookup you want
    • Right-Click on title bar – Select Debugging Environment..Watch values window
    • From the Edit Menu on the Watch Window select Add new Watch
    • Type in the variable control$ and click Add
    • You should see the lookup name in the watch window.

    Hope that helps.

    Elliott

  • 0 in reply to jepritch

    Great, thanks Elliot.  Very helpful.  Just curious - can this be used only with the oUIOBj in Sage, or can it be used with BOI in an external script/application?

     

    Also, A little off topic, but with regards to turning on debugging in a Sage 100 Advanced instance, just wondering:

    1.  Should the debugging flag in SOTA.INI be set in the server directory, the workstation directory, or both?

    2.  Have you ever had a problem where even after setting Debug=1 in SOTA.INI, you don't get the 'Debug' menu option in any of the Sage tasks?  I have had this issue in more than one client environment, and haven't been able to figure out the cause.

  • 0 in reply to Justin K

    That's what I used for finding the lookup too. Elliot's way is the best way. If you are using advanced you may want to make sure you are editing the right SOTA.ini file. Remember there is one on the workstation and one on the server.

  • 0 in reply to nronchetti

    A little correction to this thread.  Earlier I had stated that InvokeLookup() was introduced in Sage 100 ERP 2015 and this is incorrect.  Should be Sage 100 ERP 2013, my apologies.  We currently, in development on the 2015 release so it was probably in my brain when I answered.