Sage 100

 View Only
Expand all | Collapse all

Script works in Maintenance but not Inquiry

  • 1.  Script works in Maintenance but not Inquiry

    Posted 07-28-2021 14:23

    Hello,
     I have a script that creates a popup message in Item Maintenance based on the product line. This is so the memo doesn't have to be added to each item separately. It works in Item Maintenance, but not Item Inquiry. Can this work in Inquiry? What do I have to set differently?
    I tried a Post Read (works in Maint, not Inquiry), Set Initial Values (doesn't work at all), even tried as a UI script on the DMAIN or OMAIN (these don't work in either)



    sLine = ""

    retVal = oBusObj.GetValue("ProductLine$", sLine)

    If sLine = "9999" then
    msgRetVal = oSession.AsObject(oSession.UI).MessageBox("", "This is a new discounted and clearance item." & vbCRLF & "Warranty credit only (no replacement) is honored for six months from invoice date." & vbCRLF & "All Sales are final and subject to inventory on hand.")
    End If



    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------


  • 2.  RE: Script works in Maintenance but not Inquiry

    Posted 07-28-2021 14:26

    2 steps:

    1. Create a button in DMain that has your MessageBox

    If sLine="9999" Then
      sMsg = "Clearance Item Dude!"
     rMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg)
    End If

    1. PostRead that does InvokeButton to it.
      r=oScript.InvokeButton("BT_LINK_1")


    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 3.  RE: Script works in Maintenance but not Inquiry

    Posted 08-04-2021 14:44
    @Alnoor Cassim I have a follow up on this...
    One particular user gets an error after a while of using Item Inquiry. It works fine for a portion of the day, then she gets an error, then every item after that gets the error until she restarts Sage. Its like its logging something in her session & running out of room because it doesn't happen right away & she is the only user that is consistently using Item Inquiry to look up quantities all day long, so probably using it the most. Happens every day. I can't get it to happen for me using the same items.

    I don't have anything getting logged in the script; its pretty basic.

    Thoughts?!

    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------



  • 4.  RE: Script works in Maintenance but not Inquiry

    Posted 08-04-2021 17:25
    Pass the value into the script without using oBusObj?


    ------------------------------
    Kevin Moyes
    Technical Systems Analyst
    Munjal White Consulting Co.
    Toronto ON
    ------------------------------



  • 5.  RE: Script works in Maintenance but not Inquiry

    Posted 08-04-2021 18:20
    I like Kevin's idea. Try that! Just drop the trailing $ when using in the script. Also I was gonna say it sounds like a memory leak possibly since you're getting a 95 after it was working okay for a long time. There is a way to check. 

    Each task opened with the Launcher starts with 32 MB of workspace memory a.ka. session memory. It has nothing do with system RAM. Thru the process of "garbage collection" in the biz and UI objects, this memory is maintained and never runs out unless you have a memory leak. Here is another PostRead script you can add, or just add it to the existing one. First add a new button I/M Maint that does nothing. Set it to Hidden if it let's you. I'll assume it's called BT_LINK_2. This bit will set the value of DSZ into the button text. DSZ is a ProvideX system variable that shows available workspace memory.

    r=oScript.DebugPrint("About to get and show DSZ value")
    oScript.Execute("tmpDSZ = DSZ")
    vbDSZ = oScript.Evaluate("tmpDSZ")
    vbDSZFormatted = FormatNumber(vbDSZ,0,,,-1)
    oUIObj.SetControlProperty "BT_LINK_2", "Visible", 1
    oUIObj.SetControlProperty "BT_LINK_2", "Text$", "Mem=" & CStr(vbDSZFormatted)

    If vbDSZ < 1000000 Then
    sMsg = "Danger we are failing under 1 MB of available session memory. Close and re-open the screen soon."
    rMsg = oSession.AsObject(oSession.UI).MessageBox("", sMsg) 'or add to existing MessageBox
    End If

    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 6.  RE: Script works in Maintenance but not Inquiry

    Posted 08-11-2021 13:16
    So, passing the variable didn't help it.

    I setup this DSZ as the second button & I am invoking it first, but its not displaying the message, just giving the same Error 95 when I get to about 100 records. Now it displays 2 errors for each occurance, one for each button.
    I first tried both buttons in the same post-read, then I split them & have button 2 happening before button 1, but its never showing the message box. The original script still shows the message box when those conditions are correct.

    So, I set it to show in debugging & watched it as I moved to new records.
    It starts with DSZ = 24808933
    It errors when DSZ = 24155714

    What does this mean?!
    @Alnoor Cassim



    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------



  • 7.  RE: Script works in Maintenance but not Inquiry

    Posted 08-11-2021 13:35
    You can get rid of the 2nd MessageBox showing the low DSZ. If in fact the error occurs at DSZ of 24,155,714 then you are nowhere close to running out of workspace memory. It means you don't have a memory leak, that the cause of the 95 is something else. Prolly you have to come up with a different solution for Product Line 9999. Any chance you're on version 2021?

    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 8.  RE: Script works in Maintenance but not Inquiry

    Posted 08-11-2021 13:38
    No, v2019 Premium.

    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------



  • 9.  RE: Script works in Maintenance but not Inquiry

    Posted 08-18-2021 14:47
    Dang it. I really don't want to manually add a memo each time there is a new item added to this product line. Is there a way to script a new memo entry based on a product line? I can VI the existing ones, but they constantly add items too.

    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------



  • 10.  RE: Script works in Maintenance but not Inquiry

    Posted 08-18-2021 17:32
    Prolly you can script a new memo entry OTF but I don't think it would take effect at that point in PostRead to then auto-pop the memo. So you could place it as UI script for Panel PostLoad of PMain. Having said that, I went back to inspect the original premise that MessageBox didn't work in Item Inquiry on my local v2019.  Apparently it works for me and here is what I used. It is possible you have another script or mod in play that is changing the behavior of Item Inquiry?

    sProductLine = ""
    rV = oBusObj.GetValue("ProductLine$", sProductLine)
    r=oScript.DebugPrint("ProductLine = " & sProductLine)

    If sProductLine = "9999" Then

    sMsg = "This is a new discounted and clearance item." & vbCRLF & "Warranty credit only (no replacement) is honored for six months from invoice date." & vbCRLF & "All Sales are final and subject to inventory on hand."

    rMsg=oSession.AsObject(oSession.UI).MessageBox("",sMsg)

    End If

    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 11.  RE: Script works in Maintenance but not Inquiry

    Posted 08-19-2021 09:38
    @Alnoor Cassim did you cycle through like 100+ items? So if I just keep clicking the over arrow to bring up the next item, it eventually errors out on me, even though only about 5% of those actually have the conditions to display the message. When I was testing a few, it looked like it was working, but now I can reproduce it by just clicking next, next, next until it gives the Error 95. 

    I have one other script on that screen, its a Pre-Write that checks that the weight field is actually a numeric value. That's been on there for years. This should not be firing tho when I am just flying through the records. I don't have any UI scripts either.




    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------



  • 12.  RE: Script works in Maintenance but not Inquiry

    Posted 08-19-2021 12:40
    No I didn't cycle thru 100+ items. I haven't tested anything previous to my last post in fact. So are saying on your original PostRead script (before there was any BT_LINK_x button added to show the msg), it does work in Item Inquiry but sooner or later you'll run into a 95? I thought from original post it wasn't working at all to begin with which is why I suggested the InvokeButton route.

    I just tried to "fly" thru 20 of them based on PostRead stuff from my last post and seems to be ok. Almost seems like a timing issue for you. Strange question but does it work better if you slowly move through the items instead of flying thu them? About your PreWrite script, I agree that it wouldn't be firing off or interfering here. I don't know what to tell you without actually remoting in to see myself. 


    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------



  • 13.  RE: Script works in Maintenance but not Inquiry

    Posted 08-19-2021 13:10
    Originally, it did not work in Item Inquiry at all. 
    I added the button logic & it worked in Item Inquiry & when I cycled through a few items, it seemed to work fine.

    Then I heard from one user that sometime through the day it would throw that error. Then I heard from a couple more users, same thing. It was never first thing, it was after quite a while.
    She doesn't fly though them. She checks quantities all day long so she just has Item Inquiry open & moves item to item, as needed.

    I was able to reproduce it by continually going item to item. Last week is was right around 100 items. When I tested it again just now, it was more like 180 items. I opened a debug window & I just have one line showing the script firing over & over. Eventually, error 95.
    It seems like if the message box appears more often, I reach that error quicker. 

    Any of this help?


    ------------------------------
    Dana Young
    Lehman Wesley & Associates
    Lansing MI
    ------------------------------



  • 14.  RE: Script works in Maintenance but not Inquiry

    Posted 08-20-2021 14:38
    Edited by Alnoor Cassim 08-20-2021 14:41
    Thanks for clarifying the detail and sequence of events. I was able to duplicate it (to make it go quicker I used ProgressBar instead of MessageBox). In short the parent-child script solution to show any UI from the child button script that's invoked will always get a 95 at some point. I don't know the underlying reason and that would take some research. I've also never seen a 95 occur this way before either but I've never iteratively called a button before either.

    Good news is I cannot duplicate the issue if I show my ProgressBar (or MessageBox) right in the PostRead to begin with where I never InvokeButton to begin with. I know this did not work for you in Item Inquiry but does in Item Maintenance, but my suggestion is to go and troubleshoot why Item Inquiry never worked in the 1st place. It does for me and I've seen it elsewhere too. If you need help with that part, at this point I would need to remote in and take a look.

    ------------------------------
    Alnoor Cassim

    Email: alnoor@asifocus.com
    Ph: 949-689-9887
    Orange County, CA
    ------------------------------