Skip to Content
0
Former Member
Jun 04, 2008 at 06:00 PM

document lines "linenum" field in table & setcurrentline(x) in object

230 Views

Is there any relationship between the value in the linenum field in a document_lines table, like RDR1 with the rank in which that same line item appears within the list of line items returned in the documents_lines object when looping through them in sequence with the .setcurrentline(x) method?

I want to use a SQL statement to find out which, among many possible line items contains a certain value and then use the linenum field on that row to directly access that line through the appropriate object. I actually need to do it for a BP address in CRD1. I'm hoping the principle is the same for all master/line & document/ line objects. My code would look like this:

dim rs as recordset

dim sql as string

rs = ocompany.getbusinessobject(obridgerecordset) (whatever)

sql = "select linenum from crd1 where cardcode = 'abc' and street = '123 Main St'.

rs.doquery(sql)

dim oBP as businesspartners

obp = ocompany.getbusinessobject(oBusinessPartners)

obp.getbykey("abc")

obp.addresses.setcurrentline(rs.fields.field.item("linenum").value

obp.addresses.street = '456 Main St.'

obp.update

This would be a lot faster than creating a loop to run through the addresses in the bp object one-by-one and comparing the street value to my target, but of course I MUST know that the relationship is 100% reliable. My customer actually wants to merge data from two customers, so I'll be checking each address for one bp to determine if it exists or not in the other, and add when it doesn't, so it could reallly be slow to loop.

thanks in advance