Custom Action in Share

I`ll extract the information from here; http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf  and here: http://wiki.alfresco.com/wiki/Custom_Actions
This post = just to be able to quickly grab the files I need to change to add more buttons.

In the Share project (part of the my personal Eclipse setup)

/web/share/components/documentlibrary/recalculate-workflow-action.css

CONTENT:
.doclist .onActionXopus a {    background-image: url(plaatje-16.gif) !important; }

/web/share/components/documentlibrary/recalculate-workflow-action.js

CONTENT:

/** DocumentList “Recalculate Workflow ” action **/
(function() {
Alfresco.doclib.Actions.prototype.onActionRecalculateWorkflow = function DL_onActionRecalculateWorkflow(asset)  {
nodeRef = new Alfresco.util.NodeRef(asset.nodeRef);
alert(“comment MJB=” + file.nodeRef);
}
} )  ( ) ;

/config/web-extensions/site-webscripts/org/alfresco/components/documentlibrary/actions-common.get.head.ftl

…..add this line …..
<#– WF Action –>
<@link rel=”stylesheet” type=”text/css” href=”${page.url.context}/res/components/documentlibrary/recalculate-workflow-action.css” />
<script type=”text/javascript” src=”${page.url.context}/res/components/documentlibrary/recalculate-workflow-action.js”></script>
……………………………..

/config/web-extensions/site-webscripts/org/alfresco/components/documentlibrary/documentlist.get.config.xml

…..add this line …..
<action type=”action-link” id=”onActionRecalculateWorkflow” permission=”edit” label=”actions.document.recalculateWorkflow” />
…………………………

 

… there is still something missing here….

..  i’ll figure that out soon….

Logging for scripts – javascript and java

log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug

=> This one allows me to see what comment are generated in my javascripts

log4j.logger.org.alfresco.repo.workflow=debug

=> This one give me feedback from my workflow process definition (.xml)

log4j.logger.com.incentro.companyx.script.WorkflowScriptHelper=debug

=> And this one allows me to log stuff in my own created java clasess

Workflow in Javascript.

I cant’ make it more clear than this person is doing – so here’s the link to his blog ;
http://thoughtworker.in/2008/05/29/alfresco-workflow-managed-by-javascript/

Also – this can explain quite a lot.
http://docs.jboss.com/jbpm/v3/userguide/taskmanagement.html#tasktimers

But I still can manage to assign a task to a certain user….
*frown*

This seems usefull information.

11.3.3. THE PERSONAL TASK LIST


The personal task list denotes all the task instances that are assigned to a specific individual. This is indicated with the property actorId on a TaskInstance. So to put a TaskInstance in someone’s personal task list, you just use one of the following ways:
  • Specify an expression in the attribute actor-id of the task element in the process
  • Use TaskInstance.setActorId(String) from anywhere in your code
  • Use assignable.setActorId(String) in an AssignmentHandle

However; Assignable, assignable and TaskInstance cannot be called directly in javascript.

…. <time passes>

…. < more time passes>

And I`m back to messing around with the swimlanes. It seems they have priority over setting parameter in bmp-assignee and other values. So I solved it like this;

<swimlane name=”assignee”>
<assignment class=”org.alfresco.repo.workflow.jbpm.AlfrescoAssignment”>
<actor>#{people.getPerson(“incentro”)}</actor>
</assignment>
</swimlane>

Lesson learned – This week I`ll close with a succesfull working workflow and next week i`ll start adding behaviour.

Custom Actions

I added two custom actions to my alfresco environment. This was (relatively) easy to do;

(1) Add the actions you want to  web-client-config-custom.xml

...
<actions>

<action id="CreateMessage">
<permissions> <permission allow="true">Write</permission> </permissions>
<label>CreateMessage</label>
<image>/images/icons/email_users_large.gif</image>
<script>/Company Home/Data Dictionary/Scripts/CreateMessage.js</script>
<params> <param name="nodeRef">#{actionContext.nodeRef}</param> </params>
</action>

<action id="SendMessages">
<permissions> <permission allow="true">Write</permission> </permissions>
<label>SendMessages</label>
<image>/images/icons/check_out_large.gif</image>
<script>/Company Home/Data Dictionary/Scripts/SendMessages.js</script>
<params> <param name="nodeRef">#{actionContext.nodeRef}</param> </params>
</action>	

<action-group id="space_details_actions">
<action idref="CreateMessage" />
<action idref="SendMessages" />
</action-group>

<action-group id="space_browse_menu">
<action idref="CreateMessage" />
<action idref="SendMessages" />
</action-group>

</actions>

(2) Update your scripts.

– Add this to the beginning of your script

nodeRef = args["nodeRef"];
var space = search.findNode(nodeRef);

– Add this to the end of your script

var goBack = "<script>history.back();</script>";
goBack;

That should be enough to make little icons in the details of a space, which will fire of the scripts named here.