You can add a search command for the SelectEntity dialog, using the DoSearch property in the SelectEntitySettings.SelectEntityOptionsExtensibility Class. If this property is not set then the search button is not shown at all.
Below is the SelectEntity dialog with the DoSearch property set. You can see the command button for the search functionality (Encircled top right).
Below is the code sample for reference. The easiest way to test the below code would be to add it in the VaultList sample that comes along with the Vault SDK.
try { VDF.Vault.Forms.Settings.SelectEntitySettings settings = new VDF.Vault.Forms.Settings.SelectEntitySettings(); List<string> Entitylist = new List<string>(); Entitylist.Add("FILE"); // search for File entities. settings.OptionsExtensibility.DoSearch = (x,y,z) => searchFunc(Entitylist, false,z); VDF.Vault.Forms.Results.SelectEntityResults selresults = VDF.Vault.Forms.Library.SelectEntity(connection, settings); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error"); } VDF.Vault.Library.ConnectionManager.LogOut(connection);
void searchFunc(IEnumerable<string> entityClassIds, bool multiSelect, Action<IEnumerable<VDF.Vault.Currency.Entities.IEntity>> resultFunc)
{ List<VDF.Vault.Currency.Entities.IEntity> searchResults = new List<VDF.Vault.Currency.Entities.IEntity>(); FileIteration fileiter = GetFileIteration(entityClassIds.First(), "Assembly1.iam");//Name of file to be searched. searchResults.Add(fileiter); resultFunc(searchResults); }
FileIteration GetFileIteration(string EntityClassID, string nameoffile) { PropDef[] filePropDefs = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId(EntityClassID); PropDef filenamePropDef = filePropDefs.Single(n => n.DispName == "File Name"); SrchCond condition = new SrchCond() { PropDefId = filenamePropDef.Id, PropTyp = PropertySearchType.SingleProperty, SrchOper = 3, // is not empty SrchRule = SearchRuleType.Must, SrchTxt = nameoffile }; string bookmark = string.Empty; SrchStatus status = null; List<File> totalResults = new List<File>(); while (status == null || totalResults.Count < status.TotalHits) { File[] results = connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(new SrchCond[] { condition },null, null, false, true, ref bookmark, out status); if (results != null) totalResults.AddRange(results); else break; } return new FileIteration(connection ,totalResults.First()); }
When the search button is pressed, and searched file is found, the dialog then navigates to the found file, as seen below.