cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Aspects in Custom Actions

erictice
Champ in-the-making
Champ in-the-making
I created a custom action and it kicks off properly.  One thing I am curious about though.  How do I access Aspect metadata that was not set on the action itself?  For instance.  The Title and Author fields are out of box metadata that you can see on the content.  My action is kicked off on adding content to a given space.  The assumption I was making is that I would have access to all metadata on the content that is inbound when the action is kicked off.  Is that not correct?

Thank you
Eric
3 REPLIES 3

jpotts
World-Class Innovator
World-Class Innovator
If you are talking about a Java-based Action, the NodeRef the action is running against gets passed in to your executeImpl method:

protected void executeImpl(Action action, NodeRef actionedUponNodeRef)

Once you have that, you can get/set properties to your heart's content

Map<QName, Serializable> properties = nodeService.getProperties(actionedUponNodeRef);
properties.put(SomeCoModel.PROP_IS_ACTIVE, activeFlag);

If you are running JavaScript-based action, the object the action is running against is automatically available in the "document" root variable.

if (document.hasAspect("sc:webable")) {
   if (document.properties["sc:isActive"] == true) {
      document.properties["sc:isActive"] = false;
      document.properties["sc:published"] = new Date();
   
      document.save();
   }
}

Hope that helps,

Jeff

erictice
Champ in-the-making
Champ in-the-making
I need to get properties.  Are they pre-set as part of the content?

erictice
Champ in-the-making
Champ in-the-making
What would the somecomodel be if I were trying to get the Author metadata as it is an standard alfresco option not one I want to customize?
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.