Skip to Content
0

Update BP address setCurrentLine sets the row not the line

Feb 14, 2017 at 07:02 PM

252

avatar image

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.

bpsAdd.SetCurrentLine(117);

the selected row shows RowNum 123

How can I select the actual row using LineNum?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
DIEGO LOTHER Feb 14, 2017 at 11:59 PM
2

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: https://answers.sap.com/questions/112210/deleting-a-business-partner-address-using-di-sdk-g.html

"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:

SELECT 
	VisOrder 
FROM (
	SELECT 
		ROW_NUMBER() OVER(ORDER BY Address, AdresType) - 1 VisOrder, 
		Address  
	FROM 
		CRD1 
	WHERE 
		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

Share
10 |10000 characters needed characters left characters exceeded
Guy Lemire Feb 15, 2017 at 01:56 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Guy,

Great.

Don't forget to click on the accept button below my answer.

Kind Regards,

Diego Lother

0