AnsweredAssumed Answered

Create custom DocLib action

Question asked by itzamna on Oct 16, 2013
Latest reply on Oct 17, 2013 by itzamna

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:
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">
            <action id="myCompany.doclib.action.openExternal"
                <param name="function">onActionOpenExternal</param>
                <param name="successMessage">message.openExternal.success</param>
                <param name="failureMessage">message.openExternal.failure</param>
            <actionGroup id="document-browse">
                <action index="400" id="myCompany.doclib.action.openExternal" />
            <actionGroup id="document-details">
                <action index="400" id="myCompany.doclib.action.openExternal" />

And this is the custom javascript that creates the current result and invokes the webscript:

  (function() {"registerAction",
        actionName: "onActionopenExternal",
        fn: function myCompany_onActionOpenExternalProgram(file) {
                    //'<URL based on the webscript response below>') ???
                    message: this.msg("message.openExternal.success", file.displayName, Alfresco.constants.USERNAME)
                    message: this.msg("message.openExternal.failure", file.displayName, Alfresco.constants.USERNAME)
                    name: "myCompany/openExternal?nodeRef={nodeRef}&userName={userName}",
                    stem: Alfresco.constants.PROXY_URI,
                    method: Alfresco.util.Ajax.GET,
                        nodeRef: file.nodeRef,
                        userName: Alfresco.constants.USERNAME

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! :-)