Problems launching script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 05:34 AM
I would like to test the javascript backup.js.
I have created a button for lauch this script.
My web-client-config-custom.xml is the following:
<config> <actions> <!– Launch Test Javascript Dialog –> <action id="test_js"> <label>Test Javascript</label> <image>/images/icons/add.gif</image> <script>/Company Home/Data Dictionary/backup.js</script></action> <!– Add action to more actions menu for each space –> <action-group id="document_browse"> <action idref="test_js" /> </action-group> </actions> </config>
When I execute the script appears to me the following error:
org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing: Unable to resolve item Path: /Company Home/Data Dictionary/backup.js at org.alfresco.web.app.servlet.CommandServlet.service(CommandServlet.java:176) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Caused by: java.lang.IllegalArgumentException: Unable to resolve item Path: /Company Home/Data Dictionary/backup.js at org.alfresco.web.app.servlet.BaseServlet.resolveNamePath(BaseServlet.java:315) at org.alfresco.web.app.servlet.command.ScriptCommandProcessor.validateArguments(ScriptCommandProcessor.java:72) at org.alfresco.web.app.servlet.CommandServlet.service(CommandServlet.java:128) … 15 more
What is the problem??
I think that the path is correct.
Another question: Is it possible to create an action only for a single user?
Thanks.
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 11:46 AM
<script>/Company Home/Data Dictionary/backup.js</script>
</action>
What is the problem??
I think that the path is correct.
It is not correct:
<script>/Company Home/Data Dictionary/Scripts/backup.js</script>
Although there is nothing stopping you moving/copying the script to another location if you prefer.
Thanks,
Kevin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2006 11:48 AM
Another question: Is it possible to create an action only for a single user?
Yes, you can use an evaluator (see the <evaluator> tags for an action) and compare the current username with the user target for the action, which is available using the code:
org.alfresco.web.app.Application.getCurrentUser()
Thanks,
Kevin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2006 04:22 AM
where I can to find documentation about tags.
Are there links?
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2006 12:21 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2007 10:08 PM
<config> <actions> <action id="custom-action-check-in-all"> <permissions> <!– each permission can be an Allow or Deny check –> <permission allow="true">Write</permission> </permissions> <label>Check All In</label> <tooltip>Check in all documents in this space</tooltip> <show-link>true</show-link> <style>padding:4px</style> <style-class>inlineAction</style-class> <image>/images/icons/CheckIn_icon.gif</image> <script>/Company Home/Data Dictionary/Scripts/framemaker_ci.js</script> <params> <param name="id">#{actionContext.id}</param> </params> </action> <action-group id="browse_actions_menu"> <action idref="custom-action-check-out-all" /> <action idref="custom-action-check-in-all" /> </action-group> </actions> </config>
and my script:
//// Alfresco script to handle Framemaker documents.//var space = search.findNode( "workspace://SpacesStore/" + args["id"] );for (var i=0; i<space.children.length; i++ ) { var child = space.children[i]; if ( child.isDocument ) { child.checkin( "changes…" ); }}
So far so good. The script when fired does what it is supposed to do, however, it seems something is expected to be returned by the script, because as written, I get directed to a seemingly nonsense html page, with contents similar to:
org.mozilla.javascript.Undefined@198096
The alfresco.log seems happy:
19:05:57,778 DEBUG [org.alfresco.repo.jscript.RhinoScriptService] Executing script: workspace://SpacesStore/162cc14f-ed50-11db-997f-9be431dba15819:05:57,778 DEBUG [org.alfresco.repo.jscript.ScriptLogger] 22b9098c-ed50-11db-997f-9be431dba15819:05:57,848 DEBUG [org.alfresco.repo.jscript.RhinoScriptService] Time to execute script: 70ms

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2007 04:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2007 05:05 PM
var html;
function main() {
html = "<html>Hello World</html>";
}
main();
html;
Now, that is arguably not very interesting. The previous post demonstrated one way to get back into the gui:
html = "<script>history.back();</script>";
and this -is- an improvement, but not necessarily what is called for. More interesting perhaps is being able to return the user back to some space … their home space maybe, or the parent space of a child being worked on in the script perhaps. The way to do this is to use ExternalAccessServlet url (documented http://wiki.alfresco.com/wiki/URL_Addressability#ExternalAccessServlet).
For example, your script could look like:
var html;
function make_url( noderef ) {
var url = "/alfresco/navigate/browse/workspace/SpacesStore/" + noderef;
return( url );
}
function main () {
// (…)
var loc = make_url( pnode.parent.id );
html = "<script>" +
"window.location.href='" + loc + "';" +
"</script>";
}
main();
html;
I've just started playing with this, but it appears to function well. There may be issues with the back button (ajax history issues) and/or bread crum bar … so don't hold me liablle!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2007 02:04 PM
I have a different problem launching a script…
I've define the following menu item:
<!– Adding a custom menu item for adding "Pending approval" aspect after being rejected –> <config> <actions> <!– Launch Add Aspect Dialog –> <action id="return_to_PendingApproval"> <label>Return to "Pending Approval" state</label> <script>/Company Home/Data Dictionary/Scripts/applyPendingApprovalAspect.js</script> </action> <!– Add action to Actions Menu for Document Details screen–> <action-group id="doc_details_actions"> <action idref="return_to_PendingApproval" /> </action-group> <!– Add action to Actions Menu for a document in the Browse screen–> <action-group id="document_browse_menu"> <action idref="return_to_PendingApproval" /> </action-group> </actions> </config>
which refers to the following script (stored in 'Scripts' space):
document.removeAspect(“dsm:docStatus_Rejectedâ€);document.removeAspect(“dsm:docStatus_Approvedâ€);document.addAspect(“dsm:docStatus_PendingApprovalâ€);
The following aspects are defined in the model (and the model is registered without problems in the repository):
<namespaces> <namespace uri="extension.document.status.model" prefix="dsm"/> </namespaces> <!– ASPECTS definitions –> <aspects> <!– Definition of new Document Status Aspect –> <aspect name="dsm:docStatus_PendingApproval"> <title>DocumentStatus_PendingApproval</title> <!– Properties associated to this aspect –> <properties>[…] </properties> </aspect> <!– Definition of new Document Status Aspect –> <aspect name="dsm:docStatus_Rejected"> <title>DocumentStatus_Rejected</title> <!– Properties associated to this aspect –> <properties>[…] </properties> </aspect> <!– Definition of new Document Status Aspect –> <aspect name="dsm:docStatus_Approved"> <title>DocumentStatus_Approved</title> <!– Properties associated to this aspect –> <properties>[…] </properties> </aspect>
All properties for these aspects have the 'protected' tag set to 'true'.
The problem is that when i click on the menu item nothing seems to happen… The aspect (rejected or approved) is still there, and there is no sign of the pending approval aspect.
Can anyone tell me what I'm doing wrong, please?

Thanks in advance and regards,
Enrique

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2007 04:53 AM
http://wiki.alfresco.com/wiki/Externalised_Client_Actions#Action_Definition_Config_Elements
Thanks,
Kevin
