<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Narrow Search Criteria to Specific Folder - Speed Up Vault Search API in Vault Customization Forum</title>
    <link>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402396#M4166</link>
    <description>&lt;P&gt;I found this bit of code in a search and modified some of it for my needs but I'm interested in how to modify it to only search for in a specific folder to speed up my search. For Example I would like to only search to find this file in $\PARTS LIBRARY\ And not search the entire vault for the part. Is this possible?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    Private Shared Function FindVaultFileByFileName(connection As VDF.Vault.Currency.Connections.Connection, filename As String) As ACW.File

        Dim result As ACW.File = Nothing

        Dim filePropDefs As ACW.PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")


        Dim fileNamePropDef As ACW.PropDef = filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")

        Dim fileNameMatch As New ACW.SrchCond()


        fileNameMatch.PropDefId = fileNamePropDef.Id


        fileNameMatch.PropTyp = ACW.PropertySearchType.SingleProperty


        fileNameMatch.SrchOper = 3


        fileNameMatch.SrchRule = ACW.SearchRuleType.Must


        fileNameMatch.SrchTxt = filename

        Dim bookmark As String = String.Empty
        Dim searchStatus As ACW.SrchStatus = Nothing
        Dim searchResults As ACW.File() = connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {fileNameMatch}, Nothing, Nothing, False, True, bookmark, searchStatus)

        If searchResults IsNot Nothing Then

            If searchResults.Length &amp;gt; 0 Then
                result = searchResults(0)
            End If


        End If


        Return result





    End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wanting to edit the "Look In" but do it with the API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search.PNG" style="width: 475px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/746000i85A52594A1DBFA41/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search.PNG" alt="Search.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 26 Mar 2020 17:17:25 GMT</pubDate>
    <dc:creator>Tiffany_Hayden_</dc:creator>
    <dc:date>2020-03-26T17:17:25Z</dc:date>
    <item>
      <title>Narrow Search Criteria to Specific Folder - Speed Up Vault Search API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402396#M4166</link>
      <description>&lt;P&gt;I found this bit of code in a search and modified some of it for my needs but I'm interested in how to modify it to only search for in a specific folder to speed up my search. For Example I would like to only search to find this file in $\PARTS LIBRARY\ And not search the entire vault for the part. Is this possible?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    Private Shared Function FindVaultFileByFileName(connection As VDF.Vault.Currency.Connections.Connection, filename As String) As ACW.File

        Dim result As ACW.File = Nothing

        Dim filePropDefs As ACW.PropDef() = connection.WebServiceManager.PropertyService.GetPropertyDefinitionsByEntityClassId("FILE")


        Dim fileNamePropDef As ACW.PropDef = filePropDefs.[Single](Function(n) n.SysName = "ClientFileName")

        Dim fileNameMatch As New ACW.SrchCond()


        fileNameMatch.PropDefId = fileNamePropDef.Id


        fileNameMatch.PropTyp = ACW.PropertySearchType.SingleProperty


        fileNameMatch.SrchOper = 3


        fileNameMatch.SrchRule = ACW.SearchRuleType.Must


        fileNameMatch.SrchTxt = filename

        Dim bookmark As String = String.Empty
        Dim searchStatus As ACW.SrchStatus = Nothing
        Dim searchResults As ACW.File() = connection.WebServiceManager.DocumentService.FindFilesBySearchConditions(New ACW.SrchCond() {fileNameMatch}, Nothing, Nothing, False, True, bookmark, searchStatus)

        If searchResults IsNot Nothing Then

            If searchResults.Length &amp;gt; 0 Then
                result = searchResults(0)
            End If


        End If


        Return result





    End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm wanting to edit the "Look In" but do it with the API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Search.PNG" style="width: 475px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/746000i85A52594A1DBFA41/image-size/large?v=v2&amp;amp;px=999" role="button" title="Search.PNG" alt="Search.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:17:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402396#M4166</guid>
      <dc:creator>Tiffany_Hayden_</dc:creator>
      <dc:date>2020-03-26T17:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Narrow Search Criteria to Specific Folder - Speed Up Vault Search API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402464#M4167</link>
      <description>&lt;P&gt;You can add an array of folder IDs to your search. The sample code here expects the paths of folders being included, aggregates its IDs and uses the array of folder Ids in the search method:&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;/// &amp;lt;summary&amp;gt;
        /// Find 1 to many file(s) by 1 to many search criteria as property/value pairs. 
        /// Downloads first file matching all or any search criterias. 
        /// Preset Search Operator Options: [Property] is (exactly) [Value]; multiple conditions link up using AND condition.
        /// Preset Download Options: Download Children (recursively) = Enabled, Enforce Overwrite = True
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="SearchCriteria"&amp;gt;Dictionary of property/value pairs&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="MatchAllCriteria"&amp;gt;Optional. Switches AND/OR conditions using multiple criterias. Default is true&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="CheckOut"&amp;gt;Optional. File downloaded does NOT check-out as default&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="FoldersSearched"&amp;gt;Optional. Limit search scope to given folder path(s).&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;Local path/filename&amp;lt;/returns&amp;gt;
        public string GetFileBySearchCriteria(Dictionary&amp;lt;string, string&amp;gt; SearchCriteria, bool MatchAllCriteria = true, bool CheckOut = false, string[] FoldersSearched = null)
        {
            //FoldersSearched: Inventor files are expected in IPJ registered path's only. In case of null use these:
            AWS.Folder[] mFldr;
            List&amp;lt;long&amp;gt; mFolders = new List&amp;lt;long&amp;gt;();
            if (FoldersSearched != null)
            {
                mFldr = conn.WebServiceManager.DocumentService.FindFoldersByPaths(FoldersSearched);
                foreach (AWS.Folder folder in mFldr)
                {
                    if (folder.Id != -1) mFolders.Add(folder.Id);
                }
            }

            List&amp;lt;String&amp;gt; mFilesFound = new List&amp;lt;string&amp;gt;();
            //combine all search criteria
            List&amp;lt;AWS.SrchCond&amp;gt; mSrchConds = CreateSrchConds(SearchCriteria, MatchAllCriteria);
            List&amp;lt;AWS.File&amp;gt; totalResults = new List&amp;lt;AWS.File&amp;gt;();
            string bookmark = string.Empty;
            AWS.SrchStatus status = null;

            while (status == null || totalResults.Count &amp;lt; status.TotalHits)
            {
                AWS.File[] mSrchResults = conn.WebServiceManager.DocumentService.FindFilesBySearchConditions(
                    mSrchConds.ToArray(), null, mFolders.ToArray(), true, true, ref bookmark, out status);
                if (mSrchResults != null) totalResults.AddRange(mSrchResults);
                else break;
            }
            //if results not empty
            if (totalResults.Count &amp;gt;= 1)
            {
...&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:36:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402464#M4167</guid>
      <dc:creator>Markus.Koechl</dc:creator>
      <dc:date>2020-03-26T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Narrow Search Criteria to Specific Folder - Speed Up Vault Search API</title>
      <link>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402493#M4168</link>
      <description>&lt;P&gt;thank you for your quick reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/33301"&gt;@Markus.Koechl&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Mar 2020 17:43:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vault-customization-forum/narrow-search-criteria-to-specific-folder-speed-up-vault-search/m-p/9402493#M4168</guid>
      <dc:creator>Tiffany_Hayden_</dc:creator>
      <dc:date>2020-03-26T17:43:59Z</dc:date>
    </item>
  </channel>
</rss>

