AnsweredAssumed Answered

Script error when in Action Group menu

Question asked by invantix on Oct 27, 2008
Latest reply on May 7, 2009 by johanpi
I have a script that works when run from the document properties "Run Action"…execute a script…

I added the script to the menu that appears when you are browsing a document in a space (document_browse_menu).  When run the script from there I get an error that "document" is not defined.

Here is the script:

var createVersion = "true";
var space = document.parent;
var tempFolder = companyhome;

var fileName =;

var parentFolderParent=space.parent;
var destFolder = parentFolderParent.childByNamePath("Approved");

var destFile = destFolder.childByNamePath(fileName);

// Check for existing PDF

if (destFile==null){
   var success = document.move(destFolder);
else if (!destFile.hasAspect("cm:versionable")){

if (createVersion=="true"){
   var updatedVersion = document.copy(tempFolder);

   var workingCopy = destFile.checkout();;

Here is the excerpt from web-client-config-custom.xml

   <config evaluator="node-type" condition="rg:approvableType">
         <action id="NB_approve_action">
               <permission allow="true">Write</permission>
            <label>NBApprove Action</label>
            <script>/Company Home/Data Dictionary/Scripts/ApproveDoc.js</script>
               <param name="noderef">#{actionContext.nodeRef}</param>
      <action-group id="document_browse_menu">
         <action idref="preview_doc" hide="true" />
         <action idref="update_doc" hide="true" />
         <action idref="cancelcheckout_doc" hide="true" />
         <action idref="approve_doc" hide="true" />
         <action idref="reject_doc" hide="true" />
         <action idref="cut_node" hide="false" />
         <action idref="copy_node" hide="false" />
         <action idref="start_workflow" hide="true" />
         <action idref="NB_approve_action" />

Here is the error:

org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing:
Failed to execute script 'workspace://SpacesStore/3c5111ae-63e1-11dd-9e28-53b14ffe9004':
Failed to execute script 'workspace://SpacesStore/3c5111ae-63e1-11dd-9e28-53b14ffe9004':
ReferenceError: "document" is not defined. (AlfrescoScript#2)
caused by:
Failed to execute script 'workspace://SpacesStore/3c5111ae-63e1-11dd-9e28-53b14ffe9004':
Failed to execute script 'workspace://SpacesStore/3c5111ae-63e1-11dd-9e28-53b14ffe9004':
ReferenceError: "document" is not defined. (AlfrescoScript#2)