Does SetBrowseIndex work without SetBrowseFilter?

SOLVED

I would like to read through the lines of an invoice in ascending ItemCode order during a SO_InvoiceHeader Pre-Write script, but they seem to be unaffected by a SetBrowseFilter and appear in entry order. Any ideas? Here's my 5 line test case:

sItemCode = ""	
Set oLines = oBusObj.AsObject(oBusObj.Lines)
retVal1 = oLines.SetBrowseIndex("KITEM","KITEMWHSE")
retVal2 = oLines.MoveFirst
retVal3 = oLines.GetValue("ItemCode$", sItemCode)
retVal = oScript.DebugPrint("sItemCode=" & sItemCode & "; retVal1/2/3=" & retVal1 & "/" & retVal2 & "/" & retVal3)

Current (unsaved) Invoice has shipped quantities for:

6650-26-16-11
6655
1001-HON-H252

I expected to get "1001-HON-H252", but the Debug prints: "sItemCode=6650-26-11; retVal1/2/3=1/1/1"

I also tried SetBrowseIndex parameters ("KITEM",""), ("KITEMWHSE","KITEM"), ("KITEM","KITEMWHSE"), ("KITEM","KITEM") and ("KITEM","KPRIMARY") and get the same result.

  • +1
    verified answer

    I tried various attempts at use SetIndex and SetBrowseIndex against a lines object but all were unsuccessful.  So i though maybe i could use GetResultSets with an alternate key specified and it resulted in a hard error any time i specified an alternate index.  This got me thinking that the lines object actually references an *memory* table and not the physical table and it seems the various indexes of the physical table are not duplicated to the memory table.  

    Now i was able to use GetResultSets against my own newly created object handle for SO_SalesOrderDetail_Bus so you might be able to accomplish what you need to if you switch your script to the header's post-write event instead.  

    If switching to post-write isn't feasible, the only other thing i can think of at the moment would be to loop through the lines normally and grab the values you need to sort by and throw them in either a disconnected record set or a vbscript dictionary object.  If using the disconnected record set, you'll have to sort it and then loop through it whereas the dictionary object should sort automatically as keys are added.  You can add arrays as the value of the dictionary's key or just use a delimited string as the value you use can use the Split function to grab the values you need later by array index.  I often use either Chr(138) as the column delimiter if all i need to separate are columns otherwise i use Chr(30) for rows and Chr(31) for columns.

  • 0 in reply to David Speck

    I appreciate your confirming this. Unfortunately, I need to use the Pre-Write event as I am validating the records against the SO_PackageTrackingByItem table (on which the SetBrowseIndex and Filter work). I ended up scanning the oLines table for the matching record. It runs very quickly, but if a really large invoice is slow I would probably read the oLines into an Array and sort it. Thank you AGAIN!