03-20-2017 12:35 PM
Hai Everyone,
I need to create custom action "disable download document" in alfresco document actions. it means if user upload a document into alfresco, user can disable download action to the remaining users in alfresco. Can anyone help me please.
Anyone help me please...
I attached screenshots. Please find the attachments.


04-05-2017 08:29 AM
Here is the updated javascript from your post.
Make sure, you have placed this file in the tomcat\webapps\share folder rather adding them into difference place.
(function () {
var me = this;
YAHOO.Bubbling.fire("registerAction", {
actionName: "onDisableDownload",
fn: function dlA_onDisableDownload(asset) {
var node = new Alfresco.util.NodeRef(asset.nodeRef).uri;
var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
Alfresco.util.Ajax.jsonRequest({
url: url,
method: "POST",
dataObj:
{
added: ["quanticate:disableDownloadAspect"]
},
successCallback:
{
fn: function(response)
{
Alfresco.util.PopupManager.displayMessage(
{
text: "Download action disabled successfully"
});
window.location.reload();
}
},
failureCallback:
{
fn: function(response)
{
this.msg("message.failure")
}
}
});
}
});
YAHOO.Bubbling.fire("registerAction", {
actionName: "onEnableDownload",
fn: function dlA_onEnableDownload(asset) {
var node = new Alfresco.util.NodeRef(asset.nodeRef).uri;
var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
Alfresco.util.Ajax.jsonRequest({
url: url,
method: "POST",
dataObj:
{
removed: ["quanticate:disableDownloadAspect"]
},
successCallback:
{
fn: function(response)
{
Alfresco.util.PopupManager.displayMessage(
{
text: "Download action enabled successfully"
});
window.location.reload();
}
},
failureCallback:
{
fn: function(response)
{
this.msg("message.failure")
}
}
});
}
});
})();
Hope this helps you.
If not, please let me know, will help you.
04-06-2017 05:50 AM
Hai kgastaldo,
I tested this code but this code not taking any action. can you please
explain steps wise. please i need your help.
i am using alfresco-community-5.1.f
04-07-2017 06:16 AM
Are you getting error in browser console ? While using your javascript, I had issues and i fixed the javascript and posted in the prev.post.
Please let me know, what you've placed the javascript (my-custom-action.js) file ?
04-07-2017 06:40 AM
Dear muralidharand,
1) I created custom-slingshot-share-context.xml in
/alfresco/web-extension with following code
3) I created my-custom-actions.js in /webapps/share/scripts with
following code
(function () {
var me = this;
YAHOO.Bubbling.fire("registerAction", {
actionName: "onDisableDownload",
fn: function dlA_onDisableDownload(asset) {
var node = new Alfresco.util.NodeRef(asset.nodeRef).uri;
var url = Alfresco.constants.PROXY_URI +
"slingshot/doclib/action/aspects/node/" + node;
Alfresco.util.Ajax.jsonRequest({
url: url,
method: "POST",
dataObj:
{
added: ["quanticate:disableDownloadAspect"]
},
successCallback:
);
window.location.reload();
}
},
failureCallback:
}
});
}
});
YAHOO.Bubbling.fire("registerAction", ,
successCallback:
);
window.location.reload();
}
},
failureCallback:
}
});
}
});
})();
I tested these steps, but ' disable -download' button not taking any
action. if i did any mistake. please inform me friend. help me. how i need
to steps wise. please
On Fri, Apr 7, 2017 at 3:48 PM, muralidharand <community@alfresco.com>
04-07-2017 07:23 AM
My guess, you might have missed the model (repo) side changes.
I have attached all the files that I used + you required.
Please update them in your instance properly and let me know.
04-07-2017 10:13 AM
Dear Muralidharan Deenathayalan,
1) I created custom-slingshot-share-context.xml in /alfresco/web-extension with following code
<bean id="share.custom.config" class="org.springframework.extensions.config.ConfigBootstrap"
init-method="register">
<property name="configService" ref="web.config" />
<property name="configs">
<list>
<value>classpath:alfresco/web-extension/doclib-share-config.xml</value>
</list>
</property>
</bean>
<bean id="evaluator.doclib.isDisableDownloadEvaluator" parent="evaluator.doclib.action.hasAspect">
<property name="aspects">
<list>
<value>my:disableDownload</value>
</list>
</property>
</bean>
2) I created doclib-share-config.xml in /alfresco/web-extension with following code
<!-- Document Library Custom Code config section -->
<config evaluator="string-compare" condition="DocLibCustom">
<dependencies>
<js src="my-custom-action.js" />
</dependencies>
<dependencies />
</config>
<config evaluator="string-compare" condition="DocLibActions">
<actions>
<action id="disable-download" type="javascript" label="actions.disable-download">
<param name="function">onDisableDownload</param>
<evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
</action>
<action id="enable-download" type="javascript" label="actions.enable-download">
<param name="function">onEnableDownload</param>
<evaluator>evaluator.doclib.isDisableDownloadEvaluator</evaluator>
</action>
<!-- OVERRIDE ACTION Download document -->
<action id="document-download" type="link" label="actions.document.download">
<param name="href">{downloadUrl}</param>
<param name="target">_blank</param>
<evaluator>evaluator.doclib.action.downloadBrowser</evaluator>
<evaluator>evaluator.doclib.action.hasContent</evaluator>
<evaluator negate="true">evaluator.doclib.isDisableDownloadEvaluator</evaluator>
</action>
</actions>
<actionGroups>
<actionGroup id="document-browse">
<action index="101" id="disable-download" />
<action index="102" id="enable-download" />
</actionGroup>
</actionGroups>
</config>
3) I created my-custom-actions.js in /webapps/share/scripts with following code
(function () {
var me = this;
YAHOO.Bubbling.fire("registerAction", {
actionName: "onDisableDownload",
fn: function dlA_onDisableDownload(asset) {
var node = new Alfresco.util.NodeRef(asset.nodeRef).uri;
var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
Alfresco.util.Ajax.jsonRequest({
url: url,
method: "POST",
dataObj:
{
added: ["quanticate:disableDownloadAspect"]
},
successCallback:
{
fn: function(response)
{
Alfresco.util.PopupManager.displayMessage(
{
text: "Download action disabled successfully"
});
window.location.reload();
}
},
failureCallback:
{
fn: function(response)
{
this.msg("message.failure")
}
}
});
}
});
YAHOO.Bubbling.fire("registerAction", {
actionName: "onEnableDownload",
fn: function dlA_onEnableDownload(asset) {
var node = new Alfresco.util.NodeRef(asset.nodeRef).uri;
var url = Alfresco.constants.PROXY_URI + "slingshot/doclib/action/aspects/node/" + node;
Alfresco.util.Ajax.jsonRequest({
url: url,
method: "POST",
dataObj:
{
removed: ["quanticate:disableDownloadAspect"]
},
successCallback:
{
fn: function(response)
{
Alfresco.util.PopupManager.displayMessage(
{
text: "Download action enabled successfully"
});
window.location.reload();
}
},
failureCallback:
{
fn: function(response)
{
this.msg("message.failure")
}
}
});
}
});
})();
I tested these steps, but ' disable -download' button not taking any action. if i did any mistake. please inform me friend. help me. how i need to steps wise. please
04-07-2017 12:53 PM
Have you updated the model , to have the aspect? Any errors in browser console ?
04-07-2017 01:00 PM
04-07-2017 01:03 PM
You should have the aspect in your model, otherwise Alfresco Repository can't store the download/disable value.
04-07-2017 01:06 PM
Hai Muralidharan,
Can you please suggest how to create aspect ....?
Explore our Alfresco products with the links below. Use labels to filter content by product module.