I have a good idea of how I picture this script working, never dealt with UDT's but from previous post it looks like the same rules. I am just not positive on how to "loop" through the SO Invoice lines to find the value on the UDT in order to enter a value from the UDT to the SO Invoice lines. Situation; we have a UDT_ArtCharges with columns SO#, Customer Name, ART_TOTAL. When a SO is invoiced through "SO Invoice Data Entry" I want to loop through the lines to see if any of the lines contain a miscellaneous item code of "/ART" (user should add this in SO entry but sometimes doesn't), if no lines contain "/ART" I want to pull up the UDT and find that SO number being invoiced in the UDT and add a line to the invoice with the corresponding "ART_TOTAL" for that SO number. The other feature I would like is to add a "yes" or "no" option before adding the line to the invoice, something else I haven't played with yet. I've complied a mess of code from past post, which part should I focus on first to clean it up.
sCompany=oSession.CompanyCode If oSession.Updating > 0 or oSession.StartProgram <> "SO_INVOICE_UI" THEN Exit Sub if sCompany = "ROI" Then retVal = 0 invoiceType = "" retVal = oHeaderObj.GetValue("InvoiceType$", invoiceType) If invoiceType = "IN" Then strTemp = "" Set oLines = oBusObj.AsObject(oBusObj.Lines) retVal = oLines.MoveFirst() Do While Not(cBool(oLines.EOF)) retVal = oLines.GetValue("ItemCode$", strTemp) retVal = oSession.AsObject(oSession.UI).MessageBox(strTemp) retVal = oLines.MoveNext() Loop If strTemp <> "/ART" then Set oMyObj = oSession.AsObject(oSession.GetObject("CM_UDTMaint_bus","CI_UDT_ArtCharges")) retVal = oMyObj.Find(SalesOrder) retVal = 0 order = "" retVal = oBusObJ.GetValue("SalesOrderNo$", order) If retVal = order then retVal =0 oArt = "" oArt = oSession.GetObject("CM_UDTMaint_bus", "CI_UDT_ArtCharges") retVal = oBusObj.AddLine() retVal = oBusObj.SetValue("ItemCode$", "/ART") retVal = oBusObj.SetValue("ItemType$", "5") retVal = oBusObj.SetValue("Ordered$", "1") retVal = oBusObj.SetValue("UnitPrice$", "UDT_ART_TOTAL") retVal = oBusObj.Write() r = oScript.ActivateProcedure("*ALL*") If retVal<>0 Then oScript.LinesAdded = 1 End If End If End If End If End If