Sage 100

 View Only
Expand all | Collapse all

#Scripting

  • 1.  #Scripting

    Posted 05-07-2024 11:36

    We have a simple Sales Order Entry script to calculate the total QuantityOrdered if the UDF in Product Line flag is set to "Y" and populate the total into a UDF on the Sales Order Header. Script works great in Sage 100 2020 Advanced.

    When we run the script in Sage 2022 Premium the script runs but does not total the QuantityOrdered.

    The script is below:

    If oSession.CompanyCode = "TST" Then
    retMsg = oSession.AsObject(oSession.UI).MessageBox("", "script fired  ")
    'Init Variables
    sItemType=""
    sItemCode=""
    sProdLine=""
    nTotOrd=0
    sFilter=""
    set oLines = oSession.AsObject(oBusObj.Lines)
    retval=oLines.MoveFirst()
    Do Until cBool(oLines.eof)=True
    retVal=oLines.GetValue("ItemType$",sItemType)
    retVal=oLines.GetValue("ItemCode$",sItemCode)
    'retMsg = oSession.AsObject(oSession.UI).MessageBox("", sItemCode)
    If sItemType="1" then
    If IsObject(oItem)=False then
    Set oItem=oLines.AsObject(oLines.GetChildHandle("ItemCode"))
    End If
    retVal=oItem.Find(sItemCode)
    retval=oItem.GetValue("ProductLine$",sProdLine)
    'retMsg = oSession.AsObject(oSession.UI).MessageBox("", sProdLine)
    Set oProdLine=oSession.AsObject(oSession.GetObject("IM_ProductLine_svc"))
    retval=oProdLine.Find(sProdLine)
    retVal=oProdLine.GetValue("UDF_Filters$",sFilter)
    'retMsg = oSession.AsObject(oSession.UI).MessageBox("", sFilter)
    If sFilter="Y" then
    retval=oLines.GetValue("QuantityOrdered",nOrder)
    nTotOrd=nTotOrd+nOrder
    end if
    end If
    retVal=oLines.MoveNext()
    Loop
    retVal=oBusObj.SetValue("UDF_Filters",nTotOrd)
    End If



    ------------------------------
    Doug Clark
    Ardent Consulting LLC
    ------------------------------


  • 2.  RE: #Scripting

    Posted 05-07-2024 12:04

    What event are you using?  I'd think pre-totals or pre-write should work.

    Add a pop-up after the loop to confirm it is calculating the nTotOrd properly.  If it is, make sure your SO header UDF is named correctly (and is numeric) for the SetValue to work.



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



  • 3.  RE: #Scripting

    Posted 05-07-2024 13:52

    For the pop-up to confirm the nTotOrd, do something like this (after the loop):

    retMsg = oSession.AsObject(oSession.UI).MessageBox("", "nTotOrd = " & cStr(nTotOrd))



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



  • 4.  RE: #Scripting

    Posted 05-07-2024 12:07

    Maybe the nTotOrd=0 variable initialization is getting executed more than once.  Maybe try putting it as the first line or try remarking it out and see what happens.



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



  • 5.  RE: #Scripting

    Posted 05-07-2024 13:15

    Thanks for the suggestion .

     

    No luck.

     

    Doug Clark
    Senior Sage 100 Consultant

    T: 910.617.4534


    E: Doug.Clark@ArdentConsultingLLC.com


    W: www.ArdentConsultingLLC.com

     

    Book A Meeting

     






  • 6.  RE: #Scripting

    Posted 05-07-2024 13:52

    Have you tried displaying nTotOrd on the screen to see if the the correct amount is being accumulated?  Maybe it's just having an issue writing to the database.



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



  • 7.  RE: #Scripting

    Posted 05-07-2024 15:22

    We were able to have a popup display the nTotOrd to the screen.

     

    We must have not named the UDF properly because the NTotOrd is calculating correctly.

     

    Thanks for all the help.

     

    Doug Clark
    Senior Sage 100 Consultant

    T: 910.617.4534


    E: Doug.Clark@ArdentConsultingLLC.com


    W: www.ArdentConsultingLLC.com

     

    Book A Meeting

     






  • 8.  RE: #Scripting

    Posted 05-08-2024 08:33

    We added the Popup to display nTotOrd right before the SetValue Statement below and the value was correct. The UDF_Filter_Qty is not getting set,

    retVal=oBusObj.SetValue("UDF_Filter_Qty",nTotOrd)

    We tried to edit the field UDF_Filter_Qty using DSD Premium DFDM we could edit the field but the value would not hold. 

    We opened up SQL Server Management Studio to look at the table SO_SalesOrderHeader and the column for UDF_Filter_Qty is not there

    Still stuck



    ------------------------------
    Doug Clark
    Ardent Consulting LLC
    ------------------------------



  • 9.  RE: #Scripting

    Posted 05-08-2024 08:40

    If you look in MAS_System.CM_UDF, is the UDF listed there?

    If you export the UDFs is it included?

    I have a customer also on 2022 Premium who has very strange things happen to UDFs and screen customizations, and when I recently tried to export the UDFs to create a test copy on my system, a number of their UDs were not included.



    ------------------------------
    Phil McIntosh
    Friendly Systems, Inc.
    ------------------------------



  • 10.  RE: #Scripting

    Posted 05-08-2024 08:54

    If you look in MAS_System.CM_UDF, is the UDF listed there? Yes

     

    If you export the UDFs is it included? Yes

     

     

     

    Doug Clark
    Senior Sage 100 Consultant

    T: 910.617.4534


    E: Doug.Clark@ArdentConsultingLLC.com


    W: www.ArdentConsultingLLC.com

     

    Book A Meeting

     






  • 11.  RE: #Scripting

    Posted 05-08-2024 10:05
    Edited by Kevin Moyes 05-08-2024 10:05

    Did you use the new feature to save UDF updates for later?  Don't run the update from the new screen on Premium.  It causes problems like this, exactly.  You can save changes for updating later... but re-open the table manually, and update from there (not the pending changes screen).



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



  • 12.  RE: #Scripting

    Posted 05-08-2024 16:57

    The problem was we were using the Custom Office/Main/Pending Changes Summary utility to update the table and the column was not added to the table.

     

    Thank you

     

    Doug Clark
    Senior Sage 100 Consultant

    T: 910.617.4534


    E: Doug.Clark@ArdentConsultingLLC.com


    W: www.ArdentConsultingLLC.com

     

    Book A Meeting

     






  • 13.  RE: #Scripting

    Posted 05-08-2024 10:01

    Edit something simple like the UDF description and run the Update.  That should push the field out to the tables in SQL.  (I believe there are console commands to do this too... but the UDF Update should work).



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



  • 14.  RE: #Scripting

    Posted 05-08-2024 10:14

    We thought the UDF might have been a problem, and I deleted the old UDF and created a new one.

     

    However, I did update the pending changes using the new utility.

     

    I will have to get everyone out of the system to test updating and not using the utility.

     

    Thanks

     

    Doug Clark
    Senior Sage 100 Consultant

    T: 910.617.4534


    E: Doug.Clark@ArdentConsultingLLC.com


    W: www.ArdentConsultingLLC.com

     

    Book A Meeting

     






  • 15.  RE: #Scripting

    Posted 05-09-2024 09:36

    Any chance you can maybe instead leverage the 'Item Pricing by Total Quantity' feature in S/O?  I was actually just working with it yesterday for a client.



    ------------------------------
    Brett Zimmerman
    Net at Work
    Greater Boston Area
    ------------------------------