Scripting

  • 1.  Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 06:42
    Have 2 scripts in PO Entry. 1st script calculates the item weight per line & puts it into UDF_Extended_Weight. This works fine. 2nd script needs to add up all the Extended Weights & put the total on the Totals tab. I have it as a PreTotals on the PO Header & I am getting an Error 88: Invalid/Unknown Property Name. Running in Standard 100, v2015, ABC company on my test system. When I review the trace window, it loops through 52 times for 2 line items, but each time it is calculating the Total Weight correctly. So, not sure if it is an issue with the loop, like its not stopping correctly, or if its the write portion at the end. I get the error as soon as I move to the Totals tab. Thanks in advance! Here is the script: dbgRetVal = oScript.DebugPrint(""Made it to PreTotals"") ExtWeight=0 RunWeight=0 sItemType = """" Set oLines = oBusObj.AsObject(oBusObj.Lines) dbgRetVal = oScript.DebugPrint(""After SET oLines before oLines.MoveFirst() "") retVal = oLines.MoveFirst() Do Until (cBool(oLines.Eof)) retval = oLines.GetValue(""UDF_EXTENDED_WEIGHT"",ExtWeight) retval = oLines.GetValue(""ItemType$"", sItemType) dbgRetVal = oScript.DebugPrint(""Ext Weight is "" & ExtWeight) If sItemType = ""1"" Then RunWeight = RunWeight+ExtWeight Else RunWeight = RunWeight End If dbgRetVal = oScript.DebugPrint(""Total Weight is "" & RunWeight) retval = oLines.MoveNext() dbgRetVal = oScript.DebugPrint(""After MoveNext() and Before Loop "") Loop If oLines.Eof Then retVal = oBusObj.SetValue(""UDF_TOTAL_WEIGHT"",RunWeight) retWrite = oBusObj.Write() End If


  • 2.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 06:57
    Do you have another script on the PO tables that could be recursively triggering the Pre-Totals event? Perhaps add a debug message after the loop to verify the exit condition is effective.


  • 3.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:05
    I'm not sure if that last If oLines.Eof is necessary since it should only execute after the Loop is exited at EoF. Also, are you be able to use built-in Data Sources UDF_TOTAL_WEIGHT = Total From PO_Header UDF_EXTENDED_WEIGHT


  • 4.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:05
      |   view attached
    I don't have any other scripts on the PO tables. I added a debug after the Loop & after the Write. It shows the loop message, but not the Write. Here is the last entry (#52)


  • 5.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:06
      |   view attached


  • 6.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:08
    @SteveIwanowski, I will give it a try.


  • 7.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:11
    Well, that worked & is so much easier. I guess I have never used the Sum feature in UDFs before. Thank you!!


  • 8.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:12
    Cool!


  • 9.  RE: Have 2 scripts in PO Entry. 1st script calculates

    Posted 09-12-2016 07:40
    Thanks @SteveIwanowski - I learned something new today!