Create custom DocLib action

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2013 09:37 AM
Hi,
I'm trying to create a custom DocLib action on Share that opens a new window with an URL that needs to be created by a webscript before (based on the node-ref).
I followed this example: http://ecmstuff.blogspot.de/2012/04/adding-document-library-actions-in.html
It works fine so far and it seems to be exactly what I'm looking for. But the example sends only an email and return with a message. What I need is, that the webscript should return a result that includes already the full URL. And based on this URL a new window has to be opened.
It fails on my missing knowledge in creating the custom javascript with the Yahoo stuff… 😞
The DocLib (share-config-custom.xml) that creates the new action is defined as:
And this is the custom javascript that creates the current result and invokes the webscript:
As I mentioned, it works fine. My Java backed webscript on the repository tier will be invoked and I get the "message.openExternal.success" after clicking my new action in the Share GUI.
Maybe anyone of you would be so kind to give me some tips on how I can solve this issue? Is this an adequate approach at all? Or are the other / better approaches? If not, how can I get the result of the webscript section and open a new popup with the result value?
Many thanks! 🙂
I'm trying to create a custom DocLib action on Share that opens a new window with an URL that needs to be created by a webscript before (based on the node-ref).
I followed this example: http://ecmstuff.blogspot.de/2012/04/adding-document-library-actions-in.html
It works fine so far and it seems to be exactly what I'm looking for. But the example sends only an email and return with a message. What I need is, that the webscript should return a result that includes already the full URL. And based on this URL a new window has to be opened.
It fails on my missing knowledge in creating the custom javascript with the Yahoo stuff… 😞
The DocLib (share-config-custom.xml) that creates the new action is defined as:
<config evaluator="string-compare" condition="DocLibActions"> <actions> <action id="myCompany.doclib.action.openExternal" icon="myCompanyIcon" type="javascript" label="actions.myCompany.openExternal"> <param name="function">onActionOpenExternal</param> <param name="successMessage">message.openExternal.success</param> <param name="failureMessage">message.openExternal.failure</param> <evaluator>myCompany.doclib.action.openExternal</evaluator> </action> </actions> <actionGroups> <actionGroup id="document-browse"> <action index="400" id="myCompany.doclib.action.openExternal" /> </actionGroup> <actionGroup id="document-details"> <action index="400" id="myCompany.doclib.action.openExternal" /> </actionGroup> </actionGroups> </config>
And this is the custom javascript that creates the current result and invokes the webscript:
(function() { YAHOO.Bubbling.fire("registerAction", { actionName: "onActionopenExternal", fn: function myCompany_onActionOpenExternalProgram(file) { this.modules.actions.genericAction( { success: { //window.open('<URL based on the webscript response below>') ??? message: this.msg("message.openExternal.success", file.displayName, Alfresco.constants.USERNAME) }, failure: { message: this.msg("message.openExternal.failure", file.displayName, Alfresco.constants.USERNAME) }, webscript: { name: "myCompany/openExternal?nodeRef={nodeRef}&userName={userName}", stem: Alfresco.constants.PROXY_URI, method: Alfresco.util.Ajax.GET, params: { nodeRef: file.nodeRef, userName: Alfresco.constants.USERNAME } }, config: { } }); } });})();
As I mentioned, it works fine. My Java backed webscript on the repository tier will be invoked and I get the "message.openExternal.success" after clicking my new action in the Share GUI.
Maybe anyone of you would be so kind to give me some tips on how I can solve this issue? Is this an adequate approach at all? Or are the other / better approaches? If not, how can I get the result of the webscript section and open a new popup with the result value?
Many thanks! 🙂
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2013 01:42 AM
If you give your success option a callback rather than a message you should be able to navigate in that. So
success: { callback: { fn: function DL_oAEO_success(data) { // Navigate here } } }

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2013 07:57 AM
Hi,
I'm facing a similar issue, i would like to run a back-end action but then need to call a custom javascript function on success.
Looking at :
http://sharextras.org/jsdoc/share/community-head/symbols/Alfresco.doclib.Actions.html#onActionSimple...
I see i can use this declaration in share-config-custom.xml, right ?
But it displays the failure message when i run the action.
When i use a successMessage instead of success callback it works.
So, where the callback javascript function need to declared or register somewhere ? For now i just declare it in js file.
Thank you.
I'm facing a similar issue, i would like to run a back-end action but then need to call a custom javascript function on success.
Looking at :
http://sharextras.org/jsdoc/share/community-head/symbols/Alfresco.doclib.Actions.html#onActionSimple...
I see i can use this declaration in share-config-custom.xml, right ?
<action id="document-workitem" type="javascript" label="actions.document.addtoworkitem" icon="toworkitem"> <param name="function">onActionSimpleRepoAction</param> <param name="action">imaging.toworkitem</param> <param name="success">goToWorkItem</param> <param name="failureMessage">message.addtoworkitem.failure</param> <evaluator negate="true">evaluator.doclib.metadata.hasAspectWorkItem</evaluator> </action>
But it displays the failure message when i run the action.
When i use a successMessage instead of success callback it works.
So, where the callback javascript function need to declared or register somewhere ? For now i just declare it in js file.
Thank you.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2013 08:23 AM
Thank you Bob!
I'm now able to execute with the callback option my own javascript function:
I'm now able to execute with the callback option my own javascript function:
…this.modules.actions.genericAction({ success: { callback : { scope: this, fn: function(object) { //var result = eval("(" +object.serverResponse.responseText+")"); window.open(object.serverResponse.responseText, "_new"); } }, event: { name: "metadataRefresh" } }, failure: { message: this.msg("message.openExternal.failure", file.displayName, Alfresco.constants.USERNAME) }, webscript: { …
