API-EPDM IEdmSearch7 - How to return only the latest results?

hello, first post, prob. posting in the wrong section. Question: I have a small Add-In that I am working on and I am trying to find all files that match a certain variable.

I have a variable called ECN and I want my search to return all latest versioned files that match a certain value, but my results include all versioned files. This wouldn't be so terrible if I had a way of checking if this is the latest version, then I could filter it... but the result object seems to have latest version/ID info.

My search result object ID/Version properties both list the latest version in the vault, but that is wrong. For example, when I do the search in EPDM... the version that is found is 57 (Found in Version) when the latest is 66. My API object version says 66 (see attached image)

Question: What is the best-cleanest method of running a search on EPDM and returning only the latest files? Again my search result object seems wrong... the version and ID are both the latest.

The basics of my code:

 

Dim

search As IEdmSearch7

search = v.CreateSearch

search.FindFiles = True

search.FindFolders = False

search.AddVariable("ECN", ECN)

'search.AddVariable("Search Previous Versions", "0")'thought this may work... took it from the search card variable list

Dim sr As IEdmSearchResult5 = Nothing

sr = search.GetFirstResult

     

Do While Not sr Is Nothing

     'do a bunch of stuff

     'sr.version=66 (wrong this is the latest version)

     'sr.ID=1952 (wrong... this is the latest ID)

     sr = search.GetNextResult

Loop

Any ideas?

SolidworksSolidworks Pdm enterprise Pdm