Sage 100

 View Only
  • 1.  oBusObj not accessible in button script

    Posted 06-25-2019 18:14
    According to some other scripts that are working at other customers and several examples from Alnoor's Scripting class, scripts in Custom Office automatically have a reference to oBusObj, and a SalesOrderLines script can have:
    oLines = oBusObj.AsObject(oBusObj.Lines).

    However on a system today I am getting "OLE Error 424 Object Required oBusObj".

    Any ideas on what could be wrong and how to fix?
    2017.05 Premium if that matters

    #scripting



    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------


  • 2.  RE: oBusObj not accessible in button script

    Posted 06-25-2019 18:17
    Button scripts must be set to run from the server, not the workstation, in order to have access to business objects.  It is a selection where you configure the button in Customizer.

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



  • 3.  RE: oBusObj not accessible in button script

    Posted 06-25-2019 18:19
    3 thoughts:

    1. You have Execute Script on Client set in the button properties within Customizer. Change to Execute Script on Server. 
    2. You don't have External Access turned on in Company Maintenance. Hey I know, unlikely but if you just made a Copy company then take a look.
    3. Old problem with Premium that shouldn't still be a problem. On App Server the masSql.Settings file in \mas90\Home, the "Driver=" info on the CONNECT= line is malformed.


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

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 4.  RE: oBusObj not accessible in button script

    Posted 06-25-2019 20:16
    Uggh - I need to make sure the line has been written (oLines.Write)) and then call an external program to run on the client with the contents of certain fields as arguments...

    Any ideas on workarounds?  Is there  a way to call two scripts from one button?

    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------



  • 5.  RE: oBusObj not accessible in button script

    Posted 06-25-2019 21:38

    Yep. So below is a snippet from a larger Pre-Validation on CustomerName script I did to reject a duplicate customer name keyed into Cust Maint. Main logic runs first to ID a dupe customer name was found then 2nd script PlaySoundWkstn.vbs runs from client to audibly speak the words "This customer name is already used". It uses the Windows Text To Speech (TTS) API. Although you don't need sound the principles are otherwise same for your button but set Execute Script on Server so can you do your oLines.Write() first then fire off client script at the end.

    Arguments: I didn't need to pass any myself but it shouldn't be a problem:
    * Append your args to the vbsCMD below
    * Inside 2nd script use WScript.Arguments(n) to evaluate the args. Here's an example - VBS ex on using args
    * I seem to recall needing to name 2nd script with a .VBS extension (not .TXT)

    If oSession.CS Then 'CS means running on Adv or Premium

    'Set location for Workstation Script.
    WkstnScript = oSession.PathCSRoot + "CM\Script\PlaySoundWkstn.vbs" 'Substitute w/ your VBS

    WSH = "WScript.exe " 'May need to hard-code that to C:\Windows\SysWow64\WScript.exe
    vbsCMD = CHR(34) & WSH & WkstnScript & CHR(34) 'Form the o/s cmd to run it. Add args here too.
    oScript.Execute("ShellCMD$ = " & vbsCMD) 'Pass the cmd into a pvx variable ShellCMD$

    'Fire off the script at the workstation. The [wdx] indicates run from the client.
    oScript.Execute("CALL "+CHR(34)+"[wdx]SYZDLL;SHELL_AND_WAIT"+CHR(34)+",ShellCMD$")

    Else

    'Tap into TTS feature. More info can be found here: http://goo.gl/cM6dYJ
    If IsObject(oVoice) = False Then
      Set oVoice = CreateObject("SAPI.SpVoice")
    End If

    Words = "This customer name is already used."
    retVal = oVoice.Speak(Words)

    End If



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

    Free Agent Developer and Consultant
    CallForHelp.biz
    Email: alnoor@callforhelp.biz
    Orange County, CA
    ------------------------------



  • 6.  RE: oBusObj not accessible in button script

    Posted 06-26-2019 08:07
    Thank you @Alnoor Cassim!​

    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------



  • 7.  RE: oBusObj not accessible in button script

    Posted 06-26-2019 08:20
    @Alnoor Cassim - is there an alternate to SHELL_AND_WAIT that doesn't leave the Sales Order screen hanging​?  I tried "SHELL" and "SHELL_AND_CONTINUE" and "SHELL_AND_RUN" but none of those work...

    ------------------------------
    Phil McIntosh
    President
    Friendly Systems, Inc.
    Asheville NC
    678.273.4010 ext 5
    ------------------------------



  • 8.  RE: oBusObj not accessible in button script

    Posted 06-26-2019 11:19
    Edited by Alnoor Cassim 06-26-2019 15:32
    ** EDIT ** - Just tested now. Made some adjustments below to both the Execute's.

    ______________________________________
    It's running the Windows WaitForSingleObject() function from Kernel32. IOW it's waiting for you to finish executing your client side program. If you are launching a Word doc, then it's waiting for you to close Word. It's just like the Preview button in reports.

    I haven't tested this but this uses pvx INVOKE (runs CMD /C in the o/s). The [wdx] means run client-side.
     
    oScript.Execute "ShellCMD$=" + CHR(34) + "[wdx]" + CHR(34) + vbsCMD
    oScript.Execute "INVOKE STP(ShellCMD$,3,CHR(34))"

    ______________________________________