I am trying to use filters to update BO records that match certain criteria.
I took the code form the help file in which you update an active flag on a record. I am tryingto do much the same thing but it does not work as I expected.
When I first apply the filter, the record count is 5 (bo.count property is 5) and properly displays the correct records in CurrentView, as the code loops through it changes the count on the BO on the fly, decrementing by one. I did not expect this until I saved the changes after the loop, as a result only three records get the flag field changed (only three lines get written out to the console) and the BO.save call fails with an index exception.
Any thoughts?
Private Sub SortAndFilterSample()
'-- Sort the products by name and price
ProductsBO1.Sort = "prod_name, prod_price DESC"
'-- Only show active records
ProductsBO1.Filter = "prod_isactive=1"
'-- Iterate through all of the filtered rows and
' deactivate the products
If ProductsBO1.MoveFirst() Then
Do
'-- Write the product name to the Visual Studio console
Console.WriteLine(ProductsBO1.prod_name)
'-- De-activate
ProductsBO1.prod_isactive = False
Loop While ProductsBO1.MoveNext()
End If
End Sub
Keith Chisarik