Filter BO2 "where BO2 pk not in (Select fkBO2 from BO1)"


Author
Message
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I have a BO1 typed to a table which has an FK that is the PK of BO2 ( no relationship setup between the BOs )



I want to filter BO2 to exclude records where the pk is found in the FKs of BO1



Guidance as to SF best practice for this appreciated Smile







Reply
Charles R Hankey
Charles R Hankey
StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)StrataFrame VIP (1.3K reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I reread your post, Trent, and thought I might be missing something glaringly obvious ( Lord knows it would not be the first time Smile )



I thought perhaps you were telling me that the



MyBO2.Filter = "FKField = " + MyBO1.PK.ToString()




would test FKField against a collection of all the pks in MyBO1. I even tried it as MyBO1.PK().Tostring()



But it seems it just compares it to the currentrow value, so would only get one record. Did I misunderstand or do it wrong or it that just the way it is?



I created a function to return a string of integers from my keylist and can build the filter that way, but I still feel there is some magic I'm missing



( I thought this function might already exists somewhere in the framework but couldn't find it )



Public Shared Function keyarraytoString(ByVal keyarray As List(Of System.Int32)) As String

Dim keystring As String = ""



For Each key In keylist

keystring += key.ToString()

If keylist.IndexOf(key) <> keylist.Last Then

keystring += ","

End If

Next



Return keystring



End Function





So then I filter my templates :



Me.TemplatesBO1.Filter = "ikey not in (" & keystring & ")"




It works fine and I can certainly create overloads of the function to handle other types in the passed in list.



But I can't help but feel that while it is a solution it is not the solution. Cool



GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search