01-30-2020 11:25 AM
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
01-31-2020 11:36 AM
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...
01-30-2020 11:53 AM
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.
01-30-2020 12:11 PM
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
01-31-2020 08:28 AM
Hi @jasonzhang,
A guide to the API is available here https://docs.alfresco.com/6.1/concepts/dev-api-intro.html
HTH
01-31-2020 11:36 AM
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...
02-03-2020 09:44 AM
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!
Explore our Alfresco products with the links below. Use labels to filter content by product module.