<?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: How to know the folder which triggered action in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146782#M38859</link>
    <description>&lt;P&gt;How do you want to know what is the folder where the rule triggered?&lt;/P&gt;&lt;P&gt;You can still use &lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/43097"&gt;@openpj&lt;/A&gt;&amp;nbsp;code snippets to log that folder.&lt;/P&gt;&lt;P&gt;If your problem is that you want to know the name of the folder you have to edit that code snippet in this way:&lt;/P&gt;&lt;PRE&gt;//Assuming you are injecting the NodeService using Spring Dependency Injection
ChildAssociationRef childAssociationRef = nodeService.getPrimaryParent(actionedUponNodeRef);
NodeRef parentRef = childAssociationRef.getParentRef();
String parentRefName = (String) nodeService.getProperty(parentRef, ContentModel.PROP_NAME);

log.info("Custom action triggered by folder " + parentRefName + " with nodeRef: " + parentRef);&lt;/PRE&gt;&lt;P&gt;Otherwise if you need to send this information somewhere else you should create a custom logic that sends it but still using this base mechanism inside your java action.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2024 08:49:05 GMT</pubDate>
    <dc:creator>robinp</dc:creator>
    <dc:date>2024-04-18T08:49:05Z</dc:date>
    <item>
      <title>How to know the folder which triggered action</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146778#M38855</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm using ECM 7.2 and I have a folder with a rule configured.&lt;/P&gt;&lt;P&gt;This rule triggers a custom java action and it can be configured in multiple folders.&lt;/P&gt;&lt;P&gt;Through the java API, when the action is running, is it possible to know which folder triggered this action?&lt;/P&gt;&lt;P&gt;-- EDIT&lt;/P&gt;&lt;P&gt;I forgot to mention that the rule is in a parent folder and has the option 'Apply to subfolders' checked. So, whenever this action is triggered, I would like to know if it was triggered in the most upper level folder or in one of its children.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 08:48:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146778#M38855</guid>
      <dc:creator>franciscoduarte</dc:creator>
      <dc:date>2024-04-16T08:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to know the folder which triggered action</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146779#M38856</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Java actions usually have a method defined like this:&lt;/P&gt;&lt;PRE&gt;public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef) { &lt;BR /&gt;   ... your code ... &lt;BR /&gt;} &lt;/PRE&gt;&lt;P&gt;That "actionedUponNodeRef" is often a node child of your folder, so it should be easy for you to retrieve the parent folder(where the rule was triggered) using NodeService or similar.&lt;/P&gt;&lt;P&gt;I say "often" because there are cases where&amp;nbsp;your rule is configured in a different way but you should apply this tip anyway for your scope.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 13:11:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146779#M38856</guid>
      <dc:creator>robinp</dc:creator>
      <dc:date>2024-04-17T13:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to know the folder which triggered action</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146780#M38857</link>
      <description>&lt;P&gt;In your Java action you can retrieve the primary parent related to the current node where the action is executed following these steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Get the primary parent from the current NodeRef returning a Child Association Reference&lt;/LI&gt;
&lt;LI&gt;Get the Parent Reference&lt;/LI&gt;
&lt;LI&gt;Store or log this information&lt;/LI&gt;
&lt;/OL&gt;
&lt;PRE&gt;//Assuming you are injecting the NodeService using Spring Dependency Injection&lt;BR /&gt;ChildAssociationRef&amp;nbsp;childAssociationRef = nodeService.getPrimaryParent(actionedUponNodeRef);
NodeRef parentRef = childAssociationRef.getParentRef();
log.info("Custom action triggered by folder node: " + parentRef);&lt;/PRE&gt;
&lt;P&gt;Or if you want to display the path of the parent node see the following example:&lt;/P&gt;
&lt;PRE&gt;//Assuming you are injecting the NodeService and the PermissionService using Spring Dependency Injection&lt;BR /&gt;Path currentPath = nodeService.getPath(actionedUponNodeRef);&lt;BR /&gt;String displayPath = currentPath.toDisplayPath(nodeService, permissionService);
log.info("Custom action triggered from path: " + displayPath);&lt;/PRE&gt;
&lt;P&gt;Hope this helps&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 14:03:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146780#M38857</guid>
      <dc:creator>openpj</dc:creator>
      <dc:date>2024-04-17T14:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to know the folder which triggered action</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146781#M38858</link>
      <description>&lt;P&gt;Thanks for the answers. That really makes sense but I forgot to mention what I now added in the main post. This rule has the 'Apply to subfolders' option checked and what I really want to know is if it was triggered on the most upper level folder or in one of its subfolders.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 15:47:52 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146781#M38858</guid>
      <dc:creator>franciscoduarte</dc:creator>
      <dc:date>2024-04-17T15:47:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to know the folder which triggered action</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146782#M38859</link>
      <description>&lt;P&gt;How do you want to know what is the folder where the rule triggered?&lt;/P&gt;&lt;P&gt;You can still use &lt;A href="https://migration33.stage.lithium.com/t5/user/viewprofilepage/user-id/43097"&gt;@openpj&lt;/A&gt;&amp;nbsp;code snippets to log that folder.&lt;/P&gt;&lt;P&gt;If your problem is that you want to know the name of the folder you have to edit that code snippet in this way:&lt;/P&gt;&lt;PRE&gt;//Assuming you are injecting the NodeService using Spring Dependency Injection
ChildAssociationRef childAssociationRef = nodeService.getPrimaryParent(actionedUponNodeRef);
NodeRef parentRef = childAssociationRef.getParentRef();
String parentRefName = (String) nodeService.getProperty(parentRef, ContentModel.PROP_NAME);

log.info("Custom action triggered by folder " + parentRefName + " with nodeRef: " + parentRef);&lt;/PRE&gt;&lt;P&gt;Otherwise if you need to send this information somewhere else you should create a custom logic that sends it but still using this base mechanism inside your java action.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2024 08:49:05 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-know-the-folder-which-triggered-action/m-p/146782#M38859</guid>
      <dc:creator>robinp</dc:creator>
      <dc:date>2024-04-18T08:49:05Z</dc:date>
    </item>
  </channel>
</rss>

