Skip to Content

Update BP address setCurrentLine sets the row not the line

I am having an issue with updating TaxCodes with DI API, we need to update several hundred ship to addresses from multiple BPs and I have the process where it reads the data that are set wrong and need to be corrected. When running the update if there are a lot of ship to addresses for a BP, some of our BP's are distributors and have several hundred clients we ship directly to, when I use setCurrentLine it refers to different record i.e.


the selected row shows RowNum 123

How can I select the actual row using LineNum?

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Best Answer
    Posted on Feb 14, 2017 at 11:59 PM

    Hi Guy,

    First of all, I would like to suggest you to use the tag "SAP Business One SDK" when you have a doubt about the SDK.

    As mentioned by Edy Simon on this thread:

    "Most of objects, the setCurrentLine method never takes in LineNum. It would takes in a special ordering rank.

    ie, in Document Objects is the visOrder. In case of BPAddresses is the ordering of the Addresses sort by Address and AdresType field"

    If you want to know what is the correct parameter that you need provide to SetCurrentLine method to get the correct register, you can use this query:

    FROM (
    		ROW_NUMBER() OVER(ORDER BY Address, AdresType) - 1 VisOrder, 
    		CardCode = 'MyBPCode') T0 
    WHERE Address = 'TheAddressYouAreLookingFor'

    Or you can do a loop on the bp address and check if the address that you are reading is the address that you want.

    Hope it helps.

    Kind Regards,

    Diego Lother

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 15, 2017 at 01:56 PM

    Hi Diego,

    Thank you for the answer, it is kind of confusing having a function named SetCurrentLine that takes the parameter of LineNum doesn't actually get the line but the row, I did try your query and it worked, I will have to change a few things in my code in order to accommodate.

    This really helps and will make future changes a lot quicker.

    Thank you,

    Guy Lemire

    Add comment
    10|10000 characters needed characters exceeded