PRVS
PRVS

Reputation: 1690

Get document path and ticket from action button of Alfresco

I'm writting a custom action button and I want to get in my javascript:

(function() {
    YAHOO.Bubbling.fire("registerAction",
    {
        actionName: "onActionVerify",
        fn: function JSC_onActionVerify(record) {
             var ticket = sessiontickets.getTicket();
        }
    });
})();

the path of the file that I click on the action button like:

/Data Dictionary/Email Templates/activities/activities-email.ftl

And the ticket for authentication.

I'm making this on the share client side.

Any solution for both?

My question is not duplicated because I want the path of the file in the action and my question about the tickets was to pass to the web service... I need more than the question that was on suppose "duplicated"...

Upvotes: 2

Views: 531

Answers (1)

Marco Altieri
Marco Altieri

Reputation: 3818

As usual, there are different options:

1) Call your external service directly from the browser.

In this case, you can generate the ticket and pass it to the service. The service will use it to access alfresco.

To generate the ticket you can write a webscript. Very simple webscript with the ftl that returns the session.ticket

You will not need to send username and password because you can use share as a proxy: you call /share/proxy/alfresco instead of /alfresco/service and the call is automatically authenticated.

2) The browser calls an Alfresco webscript (using share as a proxy) and the webscript calls your external service. The webscript can get the ticket from the session and pass it to the external service.

The function that receives the event when the action is clicked, as you have written in your code snipped, receives an argument: record.

One of the field of this object is the nodeRef of your file. Why do you think that you need the path? Isn't easier to use this nodeRef directly?

Anyway, if you really need the path then and you chose option 1), when you call the webscript to get the ticket, pass also the nodeRef and make the webscript return the path of the node together with the ticket. So you will call:

/share/proxy/alfresco/your-custom-webscript?nodeRef=workflow://SpaceStore/xxx...

And the webscript will return a json like:

{
    "ticket": "TICKET_121321_...",
    "qnamePath": "...."  
} 

If you chose option 2), call the webscript passing the nodeRef as in the previous example and the webscript will get the information necessary and pass it to the external service.

Upvotes: 4

Related Questions