Sage 100

 View Only
  • 1.  Script with StarShip

    Posted 03-19-2020 21:25
    Hello,
     I am trying to write a script to the SO_InvoiceHeader table to control the Print Invoice flag. It works for manual invoices, but not those brought in by StarShip, since it writes directly to the BOI.  Any idea how to help this or get it to still fire?

    Thanks! 

    #script #scripting #starship ​​​

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


  • 2.  RE: Script with StarShip

    Posted 03-19-2020 22:34
    When Starship BOI creates the invoice does your script possibly fire off but then exit prematurely because you have some exit conditions (what I've called BadStart conditions in the class script samples) that would prevent it from executing further? For example let's say you are limiting the meat of script to only run when:

    If oSession.StartProgram = "SO_INVOICE_UI"  'for Shipping Data Entry it's actually SO_SHIPPING_UI
    If oSession.ObjectInterface = 0 'OK unless a BOI app like Starship is creating your invoice

    Maybe you can post a code snippet. Also tell us which event you're using in case it's a timing thing.

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

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------



  • 3.  RE: Script with StarShip

    Posted 03-20-2020 11:13
    @Alnoor Cassim , thanks for the tip. I did have some bad start checking going on because I just put that on all of them now, so I turned that off, but it still isn't working.  ​​

    It works on manually added invoices as Table Pre-Write or Pre-Totals. I also tried Post-Write, Column PreValidate & Column PostValidate on Customer No.
    I also tried with & without retval = oBusObj.Write()
    Here is my script. Its pretty basic & easy; its just not liking StarShip.

    'BadStart = 0
    'BOI = oSession.ObjectInterface
    'InUpdate =  oSession.Updating
    'Security = oBusObj.SecurityAccess
    'StartProgram = Trim(UCase(oSession.StartProgram))
    'If Right(StartProgram, 3) = "_UI" Then UI = 1
    'If (BOI > 0 or InUpdate > 0 or Security = 0) Then BadStart = 1
    'If BadStart <> 1 Then

    If oSession.CompanyCode = "PEM" Then
    sCustomer = ""
    sPrintFlag = "N"

    retVal = oBusObj.GetValue("CustomerNo$",sCustomer)

    If sCustomer = "1003400" or sCustomer = "1003533" or sCustomer = "4422C" then
        retVal = oBusObj.SetValue("PrintInvoice$",sPrintFlag)
    End If

    End If    'Company check
    'End If    'Bad Start check

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



  • 4.  RE: Script with StarShip

    Posted 03-20-2020 16:10
    Edited by Alnoor Cassim 03-20-2020 16:11
    Check to see if script is firing off at all and if you're getting an error on the SetValue. Normally I'd say use DebugPrint or MessageBox. In this case I'd say create your own custom log file. Here is an adaptation of 1 I did for myself BECAUSE StarShip BOI was causing me woes. You can adjust it  further (e.g. add the Order No and Invoice No). Basically now everytime StarShip BOI creates an invoice / shipment, your script should fire off and write out to a CSV file that you can evaluate in Excel for errors and issues.

    BOI = oSession.ObjectInterface
     Const ForAppending = 8
    sCSVLogFile = "\\blahblahblah\moreBlah\DebugScriptWithStarShip.csv" 'optionally date and time to filename
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(sCSVLogFile,ForAppending,0)

    If oSession.CompanyCode = "PEM" Then
    sCustomer = ""
    sPrintFlag = "N"

    retVal = oBusObj.GetValue("CustomerNo$",sCustomer)
    If BOI Then sDataRow = "Script is running in PEM: Cust = " & sCustomer & ","

    If (sCustomer = "1003400" or sCustomer = "1003533" or sCustomer = "4422C") Then

       If  BOI Then sDataRow = sDataRow & "About to SetValue on PrintInvoice flag" & ","
        retVal = oBusObj.SetValue("PrintInvoice$",sPrintFlag)
        If BOI Then sDataRow = sDataRow & "SetValue result was " & retVal & ","
        If (BOI and retVal=0) Then sDataRow = sDataRow & "LastErrorMsg  was " & oBusObj.LastErrorMsg & ","

    If BOI Then objFile.Write sDataRow & vbCRLF 'Write to CSV log file

    End If

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

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------



  • 5.  RE: Script with StarShip

    Posted 03-23-2020 16:34
    This is now working. I think I had to wait for the sessions to reset at the end of the day because it keeps it active until StarShip is done with the batch. The changes on Friday are working Monday.
    Thanks so much! I think it was the "bad start" that was stopping it.

    ~Dana

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



  • 6.  RE: Script with StarShip

    Posted 03-23-2020 17:22
    Ha now you tell me :-) 
    Well now you also have a neato torpedo way to use a custom CSV log file in the future..

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

    Accounting Systems, Inc. (ASI)
    Email: alnoor@asifocus.com
    Orange County, CA
    ------------------------------