Hello,
I'm currently trying to modify an existing custom document action in Share(share-documentlibrary-config.xml), the current action is like this:
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}":
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
Solved! Go 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...
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.
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
Hi @jasonzhang,
A guide to the API is available here https://docs.alfresco.com/6.1/concepts/dev-api-intro.html
HTH
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...
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!
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.