how to get storeid in custom document action

cancel
Showing results for 
Search instead for 
Did you mean: 
jasonzhang
Member II

how to get storeid in custom document action

Jump to solution

Hello,

I'm currently trying to modify an existing custom document action in Share(share-documentlibrary-config.xml), the current action is like this:

current webdavUrl.png

In the document action, the {webdavUrl} will dynamically change to the correct string of wedavUrl, mentioned in ScriptNode:

https://docs.alfresco.com/6.1/references/API-JS-ScriptNode.html

I tried to modify {wedavUrl}  to {storeId}, restart the Alfresco, I expect to see the dynamic node ID in the link but it only shows "{storeId}":

storeId not changed.png 

I thought all ScriptNode object can be directly used here but looks like it's not. I tried {nodeRef}, it works. Can someone help me to figure out this? What did I miss?

 

Thank you, appreciate your help

1 Solution

Accepted Solutions
afaust
Master

Re: how to get storeid in custom document action

Jump to solution

The available model elements come from many sources and are effectively merged before the URL template is processed to replace placeholders. E.g. you can find URL placeholders defined in https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/actio...

The node placeholder element is based on this "class": from https://github.com/Alfresco/share/blob/master/web-framework-commons/src/main/webapp/js/alfresco.js#L...

The nodeRef sub-element is based on this object initializer: https://github.com/Alfresco/share/blob/master/web-framework-commons/src/main/webapp/js/alfresco.js#L...

You can see in the action rendering code in https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/actio...

View solution in original post

5 Replies
afaust
Master

Re: how to get storeid in custom document action

Jump to solution

ScriptNode is a Repository-tier API - the action is part of Share, so Repository-tier API is not available. You have to use some client-side JS api / model that Share provides. You should be able to use a placeholder like {node.nodeRef.storeId} in action URL templates

webdavUrl just happens to be one of the properties that are available under a similar name as in the ScriptNode API.

jasonzhang
Member II

Re: how to get storeid in custom document action

Jump to solution

Hi afaust,

Thank you for the reply. 

In your comment "You have to use some client-side JS api / model that Share provides." Here in this case, {nodeRef}, {downloadUrl}, {viewUrl}, {managePermissionsUrl} and etc are available in share-documentlibrary-config.xml because client-side JS api has already provided?

Can you let me know where I can access client-side JS api? 

Is there an example of how to impletment this? 

If I want to use a placeholder like {node.nodeRef.storeId} in action URL templates, can you let me know what are the steps I need to do to impletment this function?

 

Thank you so much

EddieMay
Alfresco Employee

Re: how to get storeid in custom document action

Jump to solution

Hi @jasonzhang,

A guide to the API is available here https://docs.alfresco.com/6.1/concepts/dev-api-intro.html

HTH

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!
afaust
Master

Re: how to get storeid in custom document action

Jump to solution

The available model elements come from many sources and are effectively merged before the URL template is processed to replace placeholders. E.g. you can find URL placeholders defined in https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/actio...

The node placeholder element is based on this "class": from https://github.com/Alfresco/share/blob/master/web-framework-commons/src/main/webapp/js/alfresco.js#L...

The nodeRef sub-element is based on this object initializer: https://github.com/Alfresco/share/blob/master/web-framework-commons/src/main/webapp/js/alfresco.js#L...

You can see in the action rendering code in https://github.com/Alfresco/share/blob/master/share/src/main/webapp/components/documentlibrary/actio...

jasonzhang
Member II

Re: how to get storeid in custom document action

Jump to solution

Hi afaust,

Thank you for the links, they are very helpful, I managed  to modify the actions.js to impletement this by adding a new function to get the node id. 

One mre question, is there a way to get the user name from the current session/token through Share tier?

 

Thank you!