cancel
Showing results for 
Search instead for 
Did you mean: 

Access file of the new page after a custom action - Alfresco

pat9rv3sousa
Champ on-the-rise
Champ on-the-rise
I make an action for documents :


<action id="documents-document" type="javascript" label="actions.documents-document" icon="documents-document">
<param name="function">onActionDocument</param>
<permissions>
<permission allow="true">Write</permission>
</permissions>
</action>


In this action, I want to call a new page created with Aikau -> something like this ->

http://docs.alfresco.com/5.0/concepts/dev-extensions-share-page-creation.html

But, I want to access the document in the new page… On the function onActionDocument I access document like:


(function() {
YAHOO.Bubbling.fire("registerAction",
{
actionName: "onActionDocument",
fn: function JSC_onActionDocument(file) {
    alert(file.nodeRef)
    alert(file.displayName)
}
}
});


But, I have another JS, FTL and XML for the new page… And in this files, how can I access the file? I try to make a POST and, now, a GET Request and pass the parameter on the URL like this:

http://localhost:8080/share/page/hdp/ws/my-new-page?file={pdfExample.pdf}

I put in the JS of the new page something like :


var a = file


but when the page is open, I obtain the 500 error Internal Server and I got "file is undefined".

How can I pass this file to the new page?
1 REPLY 1

muralidharand
Star Contributor
Star Contributor
Hi,
Can you please post example / sample files here?
You can alter the below method, to get the file querystring value.


function getNode()
{
   var queryString = page.url.getQueryString();
   var nodeRef="NOT FOUND";
  
    var stringArray = queryString.split("&");
     for(var t=0;t<stringArray.length;t++)
     { 
         if (stringArray[t].indexOf('nodeRef=')>-1){
            nodeRef = stringArray[t].split('=')[1];
            break;
         }

     }
    if (nodeRef !== "NOT FOUND")
    {
       nodeRef = nodeRef.replace("://","/");
       return nodeRef;
    }
    else
    {
        throw new Error("Node Reference is not found.");       
    }
   
}