cancel
Showing results for 
Search instead for 
Did you mean: 

Action to run script on multiple selective documents

ajbarnesy
Champ in-the-making
Champ in-the-making
Hello,

Im wanting to setup a function/action in my alfresco to be able to grab upto 4 documents in the document library and run a script that will create a new document of the documents combined and then resave them in the document library.

Does this sound possible to anyone? and can anyone give me some pointers on where to start with this?

I would very much appreciate any help.

Thanks.
6 REPLIES 6

erikwinlof
Confirmed Champ
Confirmed Champ
Hi please take a look at the following blog post:
http://blogs.alfresco.com/wp/mikeh/2011/09/26/share-document-library-extensions-in-v4-0/

…and the following link to more Share related info:
https://forums.alfresco.com/en/viewtopic.php?f=48&t=43694

Cheers & good luck, Erik

ajbarnesy
Champ in-the-making
Champ in-the-making
Hi, I read through some of the documentation on creating a custom action. Im struggling a little bit with it, and i cant really see how to make an action only for the selected items menu. The action will only be used for multiple documents, not just one.

davidcognite
Star Contributor
Star Contributor
Hello,

I can't help you with the actual act of combining the documents, but if you want to add a new multi-select action to the Doc Lib then the place to do that is in toolbar.get.config.xml which in 4.0 looks like:


<toolbar>
   <!– The create content menu can be configured in share-documentlibrary-config.xml –>
   <actionSets>
      <actionSet id="default">
         <action type="action-link" id="onActionCopyTo" label="menu.selected-items.copy" />
         <action type="action-link" id="onActionMoveTo" permission="Delete" label="menu.selected-items.move" />
         <action type="action-link" id="onActionDelete" permission="Delete" label="menu.selected-items.delete" />
         <action type="action-link" id="onActionAssignWorkflow" asset="document" label="menu.selected-items.assign-workflow" />
         <action type="action-link" id="onActionManagePermissions" permission="ChangePermissions" label="menu.selected-items.manage-permissions" />
      </actionSet>
   </actionSets>
</toolbar>

The syntax here is similar to the single document level actions, but note that you don't have access to server side evaluators since the evaluation is all done in the client when the user actually selects the items. In your case you may find the asset="document" option useful to avoid the user being able to select a folder.

The javascript actions all live in actions.js, so take a look there for how other functions work - the javascript handler you specify in the id attribute will receive a array containing the details of the selected content. You'll then be able to trigger an AJAX call to pass the nodeRefs of the selected items to a (Java backed?) webscript to do the file combining magic.

HTH,

David.

ajbarnesy
Champ in-the-making
Champ in-the-making
Hi David,

That looks mighty helpful thank you, thought it seems you definetly know what im after, would you be able to explain the function of asset="document"? Assign Workflow has asset="document" but you can still select folders with that.
and also where do i find the actions.js file? i cant seem to see it anywhere.

I havent yet looked into creating the file using the data from the other files, but from what ive researched, it may need to be in PHP

wabson
Star Contributor
Star Contributor
Hi,

It depends on what format your documents are in, but you might want to take a look at the PDF Toolkit add-on for Alfresco, which can split, combine and insert PDF-based content.

http://jared.ottleys.net/alfresco/alfresco-pdf-toolkit

Even if your original documents are not in PDF format, the repository can easily enough create a PDF rendition for most standard document types, which you could then use as a starting point.

I don't believe Jared has yet got round to adding hooks into Share to call through to the repository actions that the add-on defines, but you should be able to do that yourself and you may find you need to anyway if your action also needs to do some initial work, e.g. format conversion.

Cheers,
Will

ajbarnesy
Champ in-the-making
Champ in-the-making
It depends on what format your documents are in, but you might want to take a look at the PDF Toolkit add-on for Alfresco, which can split, combine and insert PDF-based content.

http://jared.ottleys.net/alfresco/alfresco-pdf-toolkit

Even if your original documents are not in PDF format, the repository can easily enough create a PDF rendition for most standard document types, which you could then use as a starting point.

I don't believe Jared has yet got round to adding hooks into Share to call through to the repository actions that the add-on defines, but you should be able to do that yourself and you may find you need to anyway if your action also needs to do some initial work, e.g. format conversion.

Thanks man, that looks interesting, i didnt know about the PDF toolkit. the files ill be using will be mainly excel, csv and microsoft profject though, dunno how that will handle.