As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
I have the same problem, I applied the example step by step but the custom action link does not do anything?Any idea?
… <actionSet id="document"> <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download" /> <action type="action-link" id="onActionDetails" permission="edit" label="actions.document.edit-metadata" /> … <action type="action-link" id="onActionBackup" permission="edit" label="actions.document.backup" /> </actionSet> …
/** * DocumentList "Backup" action * * @namespace Alfresco * @class Alfresco.DocumentList */ (function() { /** * Backup single document. * * @method onActionBackup * @param row {object} DataTable row representing file to be actioned */ Alfresco.DocumentList.prototype.onActionBackup = function DL_onActionBackup(row) { var file = this.widgets.dataTable.getRecord(row).getData(); this.modules.actions.genericAction( { success: { message: this._msg("message.backup.success", file.displayName) }, failure: { message: this._msg("message.backup.failure", file.displayName) }, webscript: { name: "backup/site/{site}/{container}", method: Alfresco.util.Ajax.POST }, params: { site: this.options.siteId, container: this.options.containerId }, config: { requestContentType: Alfresco.util.Ajax.JSON, dataObj: { nodeRefs: [file.nodeRef] } } }); }; })();
* Is the client side JavaScript file loaded?…1-yes client side js is loaded i see when i display the page source code …<script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script>…
It's likely because you're still using the pre-v3.2 "getRecord()" style when the wiki article states not to for v3.2 onwards. http://wiki.alfresco.com/wiki/Custom_Document_Library_Action#Action_JavaScriptCheck the "Note for V3.2" section.Thanks,MikeP.S. If you find a wiki article is "bugged" please find the time to correct it - that's what a wiki is all about!
/** * DocumentList "Backup" action * * @namespace Alfresco * @class Alfresco.DocumentList */ (function() { /** * Backup single document. * * @method onActionBackup * @param row {object} DataTable row representing file to be actioned */ alert("backup-action.js imported"); Alfresco.doclib.Actions.prototype.onActionBackup = function DL_onActionBackup(file) { this.modules.actions.genericAction( { success: { message: this.msg("message.backup.success", file.displayName) }, failure: { message: this.msg("message.backup.failure", file.displayName) }, webscript: { name: "backup/site/{site}/{container}", method: Alfresco.util.Ajax.POST }, params: { site: this.options.siteId, container: this.options.containerId }, config: { requestContentType: Alfresco.util.Ajax.JSON, dataObj: { nodeRefs: [file.nodeRef] } } }); }; })();
<script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script>
<#include "../component.head.inc"> <!– Document List –> <@link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/documentlist.css" /> <@script type="text/javascript" src="${page.url.context}/components/documentlibrary/documentlist.js"></@script> <!– Backup Action –> <@link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/backup-action.css" /> <@script type="text/javascript" src="${page.url.context}/components/documentlibrary/backup-action.js"></@script>
Web Script: org/alfresco/slingshot/documentlibrary/action/backup.post Generated from /alfresco/service/script/org/alfresco/slingshot/documentlibrary/action/backup.post on May 17, 2010 1:23:30 AM Script Properties Id: org/alfresco/slingshot/documentlibrary/action/backup.post Short Name: backup Description: Document List Action - Backup document(s) Authentication: user Transaction: required Method: POST URL Template: /slingshot/doclib/action/backup/site/{site}/{container} Format Style: argument Default Format: json Negotiated Formats: [undefined] Implementation: class org.alfresco.web.scripts.DeclarativeWebScript Extensions: [undefined] Store: workspace://SpacesStore/app:company_home/app:dictionary/cm:extensionwebscripts File: org/alfresco/slingshot/documentlibrary/action/backup.post.json.js <import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action/action.lib.js"> /** * Backup multiple files action * @method POST */ /** * Entrypoint required by action.lib.js * * @method runAction * @param p_params {object} Object literal containing files array * @return {object|null} object representation of action results */ function runAction(p_params) { var results = []; var files = p_params.files; var file, fileNode, result, nodeRef; // Find destination node var destNode = p_params.rootNode.childByNamePath("/Backup"); if (destNode == null) { destNode = p_params.rootNode.createFolder("Backup"); } // Must have destNode by this point if (destNode == null) { status.setCode(status.STATUS_NOT_FOUND, "Could not find or create /Backup folder."); return; } // Must have array of files if (!files || files.length == 0) { status.setCode(status.STATUS_BAD_REQUEST, "No files."); return; } for (file in files) { nodeRef = files[file]; result = { nodeRef: nodeRef, action: "backupFile", success: false } try { fileNode = search.findNode(nodeRef); if (fileNode === null) { result.id = file; result.nodeRef = nodeRef; result.success = false; } else { result.id = fileNode.name; result.type = fileNode.isContainer ? "folder" : "document"; // copy the node to the backup folder result.nodeRef = fileNode.copy(destNode); result.success = (result.nodeRef !== null); } } catch (e) { result.id = file; result.nodeRef = nodeRef; result.success = false; } results.push(result); } return results; } /* Bootstrap action script */ main(); File: org/alfresco/slingshot/documentlibrary/action/backup.post.json.ftl <#import "action.lib.ftl" as actionLib /> <@actionLib.resultsJSON results=results /> File: org/alfresco/slingshot/documentlibrary/action/backup.post.desc.xml <webscript> <shortname>backup</shortname> <description>Document List Action - Backup document(s)</description> <url>/slingshot/doclib/action/backup/site/{site}/{container}</url> <format default="json">argument</format> <authentication>user</authentication> <transaction>required</transaction> </webscript> Store: workspace://SpacesStore/app:company_home/app:dictionary/cm:webscripts [No implementation files] Store: classpath:alfresco/templates/webscripts [No implementation files] Store: classpath:alfresco/webscripts [No implementation files]
To ensure both these files are served to the web browser, you need to add two lines (and a suitable comment is recommended) to the documentlist.get.head.html presentation template. Question: Is the document we edit documentlist.get.html.ftl or documentlist.get.head.ftl?
http://wiki.alfresco.com/wiki/Custom_Document_Library_ActionI am also unable to get it working. A confusion on the tutorial is this: To ensure both these files are served to the web browser, you need to add two lines (and a suitable comment is recommended) to the documentlist.get.head.html presentation template. Question: Is the document we edit documentlist.get.html.ftl or documentlist.get.head.ftl?First there is no file like this: "documentlist.get.head.html".
If you can't get it working I'll be able to help (I have a working custom action), but it's been too long ago for me to remember everything I did back then…
<documentList> <actionSets> <actionSet id="empty"></actionSet> <actionSet id="document"> <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download" /> <action type="action-link" id="onActionDetails" permission="edit" label="actions.document.edit-metadata" /> <action type="action-link" id="onActionUploadNewVersion" permission="edit" label="actions.document.upload-new-version" /> <action type="action-link" id="onActionEditOnline" permission="edit,online-edit" label="actions.document.edit-online" /> <action type="action-link" id="onActionEditOffline" permission="edit" label="actions.document.edit-offline" /> <action type="action-link" id="onActionCopyTo" label="actions.document.copy-to" /> <action type="action-link" id="onActionMoveTo" permission="delete" label="actions.document.move-to" /> <action type="action-link" id="onActionDelete" permission="delete" label="actions.document.delete" /> <action type="action-link" id="onActionAssignWorkflow" label="actions.document.assign-workflow" /> <action type="action-link" id="onActionManagePermissions" permission="permissions" label="actions.document.manage-permissions" /> <action type="action-link" id="onActionManageAspects" permission="edit" label="actions.document.manage-aspects" /> <action id="onActionBackup" type="action-link" permission="" label="actions.document.backup" /> </actionSet> <actionSet id="locked"> <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download" /> </actionSet> <actionSet id="lockOwner"> <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download-original" /> </actionSet> <actionSet id="workingCopyOwner"> <action type="action-link" id="onActionUploadNewVersion" label="actions.document.upload-new-version" /> <action type="simple-link" id="onActionDownload" href="{downloadUrl}" label="actions.document.download-again" /> <action type="action-link" id="onActionCancelEditing" permission="edit" label="actions.document.cancel-editing" /> </actionSet> <actionSet id="folder"> <action type="simple-link" id="onActionMetadata" href="{folderDetailsUrl}" label="actions.folder.view-metadata" /> <action type="action-link" id="onActionDetails" permission="edit" label="actions.folder.edit-metadata" /> <action type="action-link" id="onActionCopyTo" label="actions.folder.copy-to" /> <action type="action-link" id="onActionMoveTo" permission="delete" label="actions.folder.move-to" /> <action type="action-link" id="onActionDelete" permission="delete" label="actions.folder.delete" /> <action type="action-link" id="onActionManagePermissions" permission="permissions" label="actions.folder.manage-permissions" /> <action type="action-link" id="onActionManageAspects" permission="edit" label="actions.folder.manage-aspects" /> </actionSet> <actionSet id="link"> <action type="action-link" id="onActionDelete" permission="delete" label="actions.link.delete" /> </actionSet> </actionSets> </documentList>
/** * DocumentList "Backup" action * * @namespace Alfresco * @class Alfresco.DocumentList */ (function() { /** * Backup single document. * * @method onActionBackup * @param row {object} DataTable row representing file to be actioned */ Alfresco.doclib.Actions.prototype.onActionBackup = function DL_onActionBackup(file) { alert("TEST") this.modules.actions.genericAction( { success: { message: this._msg("message.backup.success", file.displayName) }, failure: { message: this._msg("message.backup.failure", file.displayName) }, webscript: { name: "/slingshot/doclib/action/backup/site/{site}/{container}", method: Alfresco.util.Ajax.POST }, params: { site: this.options.siteId, container: this.options.containerId }, config: { requestContentType: Alfresco.util.Ajax.JSON, dataObj: { nodeRefs: [file.nodeRef] } } }); }; })();
<#include "../component.head.inc"> <!– Document List –> <@link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/documentlist.css" /> <@script type="text/javascript" src="${page.url.context}/components/documentlibrary/documentlist.js"></@script> <!– Backup Action –> <link rel="stylesheet" type="text/css" href="${page.url.context}/components/documentlibrary/backup-action.css" /> <script type="text/javascript" src="${page.url.context}/components/documentlibrary/backup-action.js"></script>
… <!– Document List –> <script type="text/javascript" src="/share/components/documentlibrary/documentlist-min.js"></script> <!– Backup Action –> <link rel="stylesheet" type="text/css" href="/share/components/documentlibrary/backup-action.css" /> <script type="text/javascript" src="/share/components/documentlibrary/backup-action.js"></script> <style type="text/css" media="screen"> @import "/share/components/documentlibrary/documentlist.css"; </style> … <div class="onActionManageAspects"><a rel="edit" href="" class="action-link" title="Manage Aspects"><span>Manage Aspects</span></a></div> <div class="onActionBackup"><a rel="" href="" class="action-link" title="Backup"><span>Backup</span></a></div> …
I have the following file:/var/lib/tomcat6/shared/classes/alfresco/web-extension/site-webscripts/org/alfresco/components/documentlibrary/actions-common.get.head.ftl, which has same contents as the original (in WEB-INF) with the following appended:<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/documentlibrary/download-pdf-action.css" /> <script type="text/javascript" src="${page.url.context}/res/components/documentlibrary/download-pdf-action.js"></script>These refer to the client side files that are needed to invoke the action.
<@link rel="stylesheet" type="text/css" href="${page.url.context}/res/components/documentlibrary/download-pdf-action.css" /> <script type="text/javascript" src="${page.url.context}/res/components/documentlibrary/download-pdf-action.js"></script>
What can be the possible reason of the fact that clicking on "Backup" action does not trigger the Javascript? Any idea?
javascript:alert(Alfresco.DocumentList.prototype.onActionBackup);
javascript:alert(Alfresco.doclib.Actions.prototype.onActionBackup);
function DL_onActionBackup(file) { this.modules.actions.genericAction({success: {message: this.msg("message.backup.success", file.displayName)}, failure: {message: this.msg("message.backup.failure", file.displayName)}, webscript: {name: "backup/site/{site}/{container}", method: Alfresco.util.Ajax.POST}, params: {site: this.options.siteId, container: this.options.containerId}, config: {requestContentType: Alfresco.util.Ajax.JSON, dataObj: {nodeRefs: [file.nodeRef]}}}); }
/** * DocumentList "Backup" action * * @namespace Alfresco * @class Alfresco.DocumentList */ (function() { /** * Backup single document. * * @method onActionBackup * @param row {object} DataTable row representing file to be actioned */ Alfresco.doclib.Actions.prototype.onActionBackup = function DL_onActionBackup(file) { this.modules.actions.genericAction( { success: { message: this.msg("message.backup.success", file.displayName) }, failure: { message: this.msg("message.backup.failure", file.displayName) }, webscript: { name: "backup/site/{site}/{container}", method: Alfresco.util.Ajax.POST }, params: { site: this.options.siteId, container: this.options.containerId }, config: { requestContentType: Alfresco.util.Ajax.JSON, dataObj: { nodeRefs: [file.nodeRef] } } }); }; })();
but please verify the action is there.
…You said but please verify the action is there. - but - how can i achive that ?
…javascript:alert(Alfresco.DocumentList.prototype.onActionBackup);…
Alfresco.DocumentList.prototype.onActionBackup = function DL_onActionBackup(file) { this.modules.actions.genericAction( … success: { message: this.msg("message.backup.success", file.displayName) }, failure: { message: this.msg("message.backup.failure", file.displayName) }, …. }
Alfresco.DocumentList.prototype.onActionBackup = function DL_onActionBackup(file) { console.log("File Node: "+file.displayName); this.modules.actions.genericAction( ….
(function() { /** * Backup single document. * * @method onActionBackup * @param file {object} Object literal representing one or more file(s) or folder(s) to be actioned */ YAHOO.Bubbling.fire("registerAction", { actionName: "onActionBackup", onActionBackup: function dlA_onActionBackup(record) { alert("TEST"); var displayName = record.displayName; var nodeRef = record.nodeRef; this.modules.actions.genericAction( { success: { event: { name: "metadataRefresh" }, message: this.msg("message.archive.success", record.displayName) }, failure: { message: this.msg("message.archive.failure",record.displayName) }, webscript: { name:"/slingshot/doclib/action/archive/site/{site}/{container}", method: Alfresco.util.Ajax.POST }, params: { site: this.options.siteId, container: this.options.containerId }, config: { requestContentType: Alfresco.util.Ajax.JSON, dataObj: { nodeRefs: [record.nodeRef] } } }); } }); })();