Sage 100

 View Only
  • 1.  Script to default customer in sales order

    Posted 12-26-2023 15:53

    HI All,   I have a customer were about 95% of their orders are from one customer.  I wrote a script to set the customer number and FOB when the Sales Order is created.  If worked ok but they changed the terms on the customer and now when the order is created, it has the wrong terms code. I tried adding the terms code to the script but it did not change the behavior.  The script if very simple, it runs on initialization.  I put the terms code last, I am wondering if moving it to before the FOB may help (I am waiting to get access to test this).   

    'Set Customer No
    'Intitalization
    sDiv = "01" : sCust = "0001101": sFOB = "HUNTINGTON PARK": sTerms = "46"

    retVal = oBusObj.SetValue("ARDivisionNo$", sDiv)
    retVal = oBusObj.SetValue("CustomerNo$", sCust)
    retVal = oBusObj.SetValue("FOB$", sFOB)
    retVal = oBusObj.SetValue("TermsCode$", sTerms)



    ------------------------------
    Bob Osborn
    Consultant
    ACI Consulting
    ------------------------------


  • 2.  RE: Script to default customer in sales order

    Posted 12-26-2023 19:09

    NOT a scripter!!!  But why not pull terms code from the customer master?



    ------------------------------
    Jeff Schwenk
    Bottomline Software, Inc.
    (540) 221-4444
    ------------------------------



  • 3.  RE: Script to default customer in sales order

    Posted 12-26-2023 19:16

    Well, @Jeff Schwenk I sort of "play" a scripter on the radio....  LOL.    Yes, it should come from the customer and if I turn off the script it does.   I just can't figure out how the script "breaks" this..



    ------------------------------
    Bob Osborn
    Consultant
    ACI Consulting
    ------------------------------



  • 4.  RE: Script to default customer in sales order

    Posted 12-27-2023 01:41
    Edited by Dan Burleson 12-27-2023 02:08

    Jeff is correct, but in Bob's case it doesn't matter from where it comes. Using ABC company, if the customer number is set, then a TermsCode '00' results instead of customer's default value. It doesn't matter if TermsCode is SetValue'd from the customer record ('02'), or SetValue'd as a constant ('02'), TermsCode '00' always results. A Column Pre-Validate and Column Post-Validate script with DebugPrint's both show when the TermsCode is set successfully (by default) as a result of changing the customer number to '02', and even though it is also successfully set again with the SetValue retVal=1, neither holds and a '00' ends up in TermsCode. This is quite strange.



    ------------------------------
    Dan Burleson
    Software Consultant
    Connex Software
    Corvallis OR
    541-224-6642
    ------------------------------



  • 5.  RE: Script to default customer in sales order

    Posted 12-27-2023 08:28

    Another thought is to default the customer and FOB using Custom Office Advanced Field Settings...you may have already thought of that and there is a reason why that won't work, but just throwing it out there.



    ------------------------------
    Susan Pawlowic
    Sage 100 Solutions Architect
    RKL eSolutions, LLC
    spawlowic@rklesolutions.com
    (717) 735-9109 Ext. 4352
    ------------------------------



  • 6.  RE: Script to default customer in sales order

    Posted 12-27-2023 08:53
    Edited by Doug Higgs 12-27-2023 08:54

    Not sure this is the best way or if it will work for you however, if you take out the TermsCode variable from the script, and add a pre-totals script to set the default terms then the terms will change once the user is directed to the totals page.

    'Only run in test company right now

    If oSession.CompanyCode <> "ABC" Then Exit Sub

    'Set Terms
    'Pre-Totals
    sTerms = "01"

    retVal = oBusObj.SetValue("TermsCode$", sTerms)



    ------------------------------
    Doug Higgs
    Midwest Commerce Solutions, Inc
    (312) 315-0960
    Chauffeur, Chef, and Personal Assistant to Sprinkles
    ------------------------------