cancel
Showing results for 
Search instead for 
Did you mean: 

Script error when in Action Group menu

invantix
Champ in-the-making
Champ in-the-making
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 = document.properties.name;var parentFolderParent=space.parent;var destFolder = parentFolderParent.childByNamePath("Approved");var destFile = destFolder.childByNamePath(fileName);// Check for existing PDFif (destFile==null){   var success = document.move(destFolder);   createVersion="false";}else if (!destFile.hasAspect("cm:versionable")){   destFile.addAspect("cm:versionable");}if (createVersion=="true"){   var updatedVersion = document.copy(tempFolder);   var workingCopy = destFile.checkout();   workingCopy.properties.content.write(updatedVersion.properties.content);   workingCopy.checkin();   updatedVersion.remove();   document.remove();}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Here is the excerpt from web-client-config-custom.xml
   <config evaluator="node-type" condition="rg:approvableType">      <actions>         <action id="NB_approve_action">            <permissions>               <permission allow="true">Write</permission>            </permissions>            <label>NBApprove Action</label>            <image>/images/icons/approve.gif</image>            <script>/Company Home/Data Dictionary/Scripts/ApproveDoc.js</script>            <params>               <param name="noderef">#{actionContext.nodeRef}</param>            </params>         </action>      <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" />      </action-group>      </actions>   </config>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

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:org.alfresco.service.cmr.repository.ScriptException: 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)‍‍‍‍‍‍‍‍‍‍‍
2 REPLIES 2

fx3000se
Champ in-the-making
Champ in-the-making
did you ever find a solution to this problem?

johanpi
Champ in-the-making
Champ in-the-making
This post works

http://forums.alfresco.com/en/viewtopic.php?f=3&t=8435&hilit=actionContext+nodeRef‍