<?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: When using an Execute Script Rule how can I determine the name of the subfolder that I am in when the rule executes? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33524#M14176</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can access the parent folder of the rule triggering document with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;document.parent&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is an alfreswco scripting node and so document.parent.name would be the name of the directory.&lt;/P&gt;&lt;P&gt;Another possibility is to use document.displayPath, that represents the whole path to the document as string. Splitting it by '/' would give you all pathelements...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Jun 2017 16:12:47 GMT</pubDate>
    <dc:creator>mehe</dc:creator>
    <dc:date>2017-06-06T16:12:47Z</dc:date>
    <item>
      <title>When using an Execute Script Rule how can I determine the name of the subfolder that I am in when the rule executes?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33523#M14175</link>
      <description>When using a javascript as the execute script rule&amp;nbsp;on a sub folder&amp;nbsp;how can I determine the name of the subfolder that I am in when the rule executes?Our subfolders are in the name of one the files custom metadata. so when moving or copying files I would like to change this piece of metadata to the n</description>
      <pubDate>Tue, 06 Jun 2017 14:51:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33523#M14175</guid>
      <dc:creator>chamill</dc:creator>
      <dc:date>2017-06-06T14:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: When using an Execute Script Rule how can I determine the name of the subfolder that I am in when the rule executes?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33524#M14176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can access the parent folder of the rule triggering document with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;document.parent&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is an alfreswco scripting node and so document.parent.name would be the name of the directory.&lt;/P&gt;&lt;P&gt;Another possibility is to use document.displayPath, that represents the whole path to the document as string. Splitting it by '/' would give you all pathelements...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards,&lt;/P&gt;&lt;P&gt;Martin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Jun 2017 16:12:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33524#M14176</guid>
      <dc:creator>mehe</dc:creator>
      <dc:date>2017-06-06T16:12:47Z</dc:date>
    </item>
    <item>
      <title>Re: When using an Execute Script Rule how can I determine the name of the subfolder that I am in when the rule executes?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33525#M14177</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The answer above was perfect and using the "displayPath" option enabled me to capture the last 3&amp;nbsp;folders of the path so I could determine which metadata to use. for anyone else who maybe in the same situation please find a version of my code below and I hope it can help someone in the future.&lt;/P&gt;&lt;P&gt;//------------------------------------------------------------&lt;/P&gt;&lt;P&gt;var vCurrentFolder&amp;nbsp;= " "&lt;/P&gt;&lt;P&gt;var vElementCount = 0&lt;/P&gt;&lt;P&gt;var pathArray = document.displayPath.split( '/' );&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Split Path into Array by backslash&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vElementCount = pathArray.length;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;// How many Elements in the Array&lt;/P&gt;&lt;P&gt;vElementCount = vElementCount - 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Number of Last Element&lt;/P&gt;&lt;P&gt;vCurrentFolder = pathArray[vElementCount];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Load Variable with Current Folder Name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;document.properties["kb:mtopic"] = vCurrentFolder ;&amp;nbsp; // Load Metadata item with Current Folder name&lt;/P&gt;&lt;P&gt;document.save();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Save Document Details&lt;/P&gt;&lt;P&gt;//-------------------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously by adjusting the vElementCount variable you can look as far back up the path as is possible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again Thank you Martin for taking the time to help me resolve this issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Jun 2017 10:50:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/when-using-an-execute-script-rule-how-can-i-determine-the-name/m-p/33525#M14177</guid>
      <dc:creator>chamill</dc:creator>
      <dc:date>2017-06-07T10:50:21Z</dc:date>
    </item>
  </channel>
</rss>

