<?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 Re: Recursive function on Alfresco JS Api ECM in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32636#M13809</link>
    <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;&lt;P&gt;I move the JS-API as you suggested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an "array" in return, with Objects in it. I can see it in console.log&lt;/P&gt;&lt;P&gt;But I can't use it. For example, array[0] returns undefined.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Oct 2019 10:11:04 GMT</pubDate>
    <dc:creator>mboquillon</dc:creator>
    <dc:date>2019-10-11T10:11:04Z</dc:date>
    <item>
      <title>Recursive function on Alfresco JS Api ECM</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32634#M13807</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to do a recursive function to get all files in a node (even if the files are in different subfolders) and to stock them into an array. But the array I return is unexploitable..&lt;/P&gt;&lt;P&gt;The code I use :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function fillArray(alfrescoJsApi: AlfrescoJSApi, node:any, array: Array&amp;lt;any&amp;gt;) {
   alfrescoJsApi.nodes.getNodeChildren(node).then( function (data) {
   for(var entry of data.list.entries) {
      if(entry.entry.isFolder == true) {
        let id = entry.entry.id;
        let newAlfrescoApi = &amp;lt;AlfrescoJSApi&amp;gt; new AlfrescoJSApi({
          provider: 'ECM'
        });
        fillArray(newAlfrescoApi, id, array);
      } else if(entry.entry.isFile == true) {
        array.push( {[entry.entry.id]: entry.entry.name});
      }
    };
    
  }, function (error) {
    console.log('This node does not exist');
  });
  return array;
}&lt;/PRE&gt;&lt;P&gt;Any ideas ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 08:18:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32634#M13807</guid>
      <dc:creator>mboquillon</dc:creator>
      <dc:date>2019-10-11T08:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive function on Alfresco JS Api ECM</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32635#M13808</link>
      <description>&lt;P&gt;First of all, I would recommend moving the JS-API outside the foreach, as you create a lot of client objects and that can hurt performance.&lt;/P&gt;
&lt;P&gt;Second, you are using async method call, and then apply for loop where you fire more async things. I think the entire function is not waiting for results correctly.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 09:26:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32635#M13808</guid>
      <dc:creator>dvuika</dc:creator>
      <dc:date>2019-10-11T09:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive function on Alfresco JS Api ECM</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32636#M13809</link>
      <description>&lt;P&gt;Thanks for the answer.&lt;/P&gt;&lt;P&gt;I move the JS-API as you suggested.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an "array" in return, with Objects in it. I can see it in console.log&lt;/P&gt;&lt;P&gt;But I can't use it. For example, array[0] returns undefined.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 10:11:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/recursive-function-on-alfresco-js-api-ecm/m-p/32636#M13809</guid>
      <dc:creator>mboquillon</dc:creator>
      <dc:date>2019-10-11T10:11:04Z</dc:date>
    </item>
  </channel>
</rss>

