PDM Searching for files that have blank variable value (never been set)
Posted: Wed Feb 26, 2025 2:23 pm
Hello,
I'm trying to find files that have a specific variable value (date type) that has never been set OR older than a date. I can get one or the other, but I'm failing to get the OR to work in one search. I'm about to just do two searches and combine results, but thought I would ask here first.
I have this and it throws exception at search.GetFirstResult() unless I only add one variable. I don't think I understand how to use begin/end AND/OR. I've tried various begin and ends and they all throw exception when adding the variable twice. This works in the Search Tool.
edit: I realized that after all that I failed to formulate a concise question. Can someone suggest how to properly use the begin/endOR, or offer link to examples or remarks in the SW online help that I've missed? I found one example where the use of BeginAND is in commented code.
I'm trying to find files that have a specific variable value (date type) that has never been set OR older than a date. I can get one or the other, but I'm failing to get the OR to work in one search. I'm about to just do two searches and combine results, but thought I would ask here first.
I have this and it throws exception at search.GetFirstResult() unless I only add one variable. I don't think I understand how to use begin/end AND/OR. I've tried various begin and ends and they all throw exception when adding the variable twice. This works in the Search Tool.
Code: Select all
try
{
IEdmSearch8 search = default(IEdmSearch8);
search = (IEdmSearch8)vault.CreateUtility(EdmUtility.EdmUtil_Search);
search.StartFolderID = vault.RootFolderID;
search.SetToken(EdmSearchToken.Edmstok_FindFolders, false);
search.SetToken(EdmSearchToken.Edmstok_FindFiles, true);
search.SetToken(EdmSearchToken.Edmstok_FindItems, false);
search.SetToken(EdmSearchToken.Edmstok_Recursive, true);
search.SetToken(EdmSearchToken.Edmstok_AllVersions, false);
search.SetToken(EdmSearchToken.Edmstok_Name, "%.sld%");
search.BeginAND();
search.BeginOR();
search.AddVariable2(LastActiveUpdater.LAST_ACT_VAR_NAME, minDate, (int)EdmVarOp.EdmVarOp_DateLessThan);
search.AddVariable2(LastActiveUpdater.LAST_ACT_VAR_NAME, "", (int)EdmVarOp.EdmVarOp_DateEqualTo);
search.EndOR();
search.EndAND();
//prime the loop
IEdmSearchResult5 searchResult = search.GetFirstResult();
while (searchResult != null)