Quantcast
Channel: Sage 100
Viewing all articles
Browse latest Browse all 36990

Forum Post: Insert New Item Code on Sales Order Line

$
0
0
Hi, I created 3 different scripts to automatically insert 3 different item codes (CRV, CRV16 and CRV18) to the sales order line tabs with pre-totals trigger. The first trigger is set to 500 priority, second one is set to 600 priority and third is set to 700 priority but for some reasons only one item is inserted at a time. The program is not inserting all the 3 item codes at the same time. Any help? Please see my scripts below. ---------------------------------------------------- if oSession.CompanyCode = "TT1" then Dim oLines MiscItem = "" UDF_TOTAL_SODA_QTY_CRV18 = 0 retVAL =oBusObj.GetValue("UDF_TOTAL_SODA_QTY_CRV18", TotalSodaQty18) if TotalSodaQty18 0 then set oLines = oBusObj.AsObject(oBusObj.Lines) retVal = oLines.MoveFirst() found = 0 do until oLines.Eof ' loop through all lines searching to find the CRV18 charge line to adjust itemCode = "" retVal = oLines.GetValue("ItemCode$", itemCode) if itemCode = "CRV18" and TotalSodaQty18 0 then retVal = oLines.SetValue("QuantityOrdered", TotalSodaQty18) ' found it, adjust the qty retVal = oLines.Write() found = 1 exit do else retVal = oscript.SetError("Nothing is set") end if retVal = oLines.MoveNext() loop if found = 0 then 'didn't find one - add it retVal = oLines.AddLine() retVal = oLines.SetValue("ItemCode$", "CRV18") retVal = oLines.SetValue("QuantityOrdered", TotalSodaQty18) retVal = oLines.Write() else retVal = oscript.SetError("Nothing is set") 'retVal = oScript.DebugPrint(Nothing is set) end if end if end if --------------------------------------- --------------------------------------- if oSession.CompanyCode = "TT1" then Dim oLines MiscItem = "" UDF_TOTAL_SODQ_QTY = 0 retVAL =oBusObj.GetValue("UDF_TOTAL_SODQ_QTY", TotalSodaQty) if TotalSodaQty 0 then set oLines = oBusObj.AsObject(oBusObj.Lines) retVal = oLines.MoveFirst() found = 0 do until oLines.Eof ' loop through all lines searching to find the CRV charge line to adjust itemCode = "" retVal = oLines.GetValue("ItemCode$", itemCode) if itemCode = "CRV" and TotalSodaQty 0 then retVal = oLines.SetValue("QuantityOrdered", TotalSodaQty) ' found it, adjust the qty retVal = oLines.Write() found = 1 exit do else retVal = oscript.SetError("Nothing is set") end if retVal = oLines.MoveNext() loop if found = 0 then 'didn't find one - add it retVal = oLines.AddLine() retVal = oLines.SetValue("ItemCode$", "CRV") retVal = oLines.SetValue("QuantityOrdered", TotalSodaQty) retVal = oLines.Write() else retVal = oscript.SetError("Nothing is set") 'retVal = oScript.DebugPrint(Nothing is set) end if end if end if --------------------------------------------------- --------------------------------------------------- if oSession.CompanyCode = "TT1" then Dim oLines MiscItem = "" UDF_TOTAL_SODA_QTY_CRV16 = 0 retVAL =oBusObj.GetValue("UDF_TOTAL_SODA_QTY_CRV16", TotalSodaQty16) if TotalSodaQty16 0 then set oLines = oBusObj.AsObject(oBusObj.Lines) retVal = oLines.MoveFirst() found = 0 do until oLines.Eof ' loop through all lines searching to find the CRV16 charge line to adjust itemCode = "" retVal = oLines.GetValue("ItemCode$", itemCode) if itemCode = "CRV16" and TotalSodaQty16 0 then retVal = oLines.SetValue("QuantityOrdered", TotalSodaQty16) ' found it, adjust the qty retVal = oLines.Write() found = 1 exit do else retVal = oscript.SetError("Nothing is set") end if retVal = oLines.MoveNext() loop if found = 0 then 'didn't find one - add it retVal = oLines.AddLine() retVal = oLines.SetValue("ItemCode$", "CRV16") retVal = oLines.SetValue("QuantityOrdered", TotalSodaQty16) retVal = oLines.Write() else retVal = oscript.SetError("Nothing is set") 'retVal = oScript.DebugPrint(Nothing is set) end if end if end if ------------------------------------------------------

Viewing all articles
Browse latest Browse all 36990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>