Obsolete Pages{{Obsolete}}
The official documentation is at: http://docs.alfresco.com
Web Client CustomizationJavaScript_API
This page aims to expand a little bit on what is described in the script section of Externalised_Client_Actions#Action_Definition_Config_Elements. What this particularly addresses is that when a script is executed using the command servlet, such as the javascript actions you expose in the Alfresco Explorer UI, the return is often of the following:
org.mozilla.javascript.Undefined@1607a8a
What this really amounts to is the Javascript engine supplying a default return, which is essentially an http response back to the browser. This is obviously not what an end user would expect after selecting an action on a document. They would expect to be taken back to where they originally executed the action from i.e. space browse, space details, document details, etc. Since the response is html, we can use this to our advantage.
// my javascript code to execute...
var goBack = '<script>history.back();</script>';
goBack;
This shows the easiest way to achieve the the effect of returning the user back to their original location. However, there are some limitations to this:
The remaining sample shows various ways to return to different views of the Alfresco Explorer for spaces and documents utilizing the URL_Addressability#ExternalAccessServlet. The ExternalAccessServlet takes URLs of the form
/alfresco/navigate/<outcome>[<workspace>/<store>/<nodeId>]
where outcome can be several appropriate strings. In the below examples, we use browse, showDocDetails, and showSpaceDetails, which are the most common redirections you would need.
var result = '<script>location.href = '/alfresco/navigate/browse/workspace/SpacesStore/' + document.parent.id + '';</script>';
result;
This will return you to the space indicated in the argument. You should be able to see the document you acted upon within this space, as well as all pre-existing documents.
var result = '<script>location.href = '/alfresco/navigate/showDocDetails/workspace/SpacesStore/' + document.id + '';</script>';
result;
This will return you to the details view of the document so that if any changes were made to properties, they would be viewed immediately in the UI. Additionally, you can perform other actions now on the document.
var result = '<script>location.href = '/alfresco/navigate/showSpaceDetails/workspace/SpacesStore/' + document.parent.id + '';</script>';
result;
This will return you to the details view of the space for the document.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.