AnsweredAssumed Answered

[Solved] Problem with move function

Question asked by olivierdz on Jan 14, 2010
Latest reply on Jan 15, 2010 by olivierdz
I created a javascript script that move a file to another space according to some parameters.
This script is automatically executed when some data in the file has changed.
The user has collaborator rights on source space and also collaborator rights on destination space.
The problem is the following :
If the user is "admin", I have no problem.
If the user is not admin, the script crash at the document.move call.
If the user is not admin and document.move is commented, the script is executed correctly.
So, I think this is a problem of rights, but I cannot find out what is the problem.
Here is the code :

var fName = "";
if (["sige:Confidential"] )
   fName = "DATA/Archives/Confidentiel";
   fName = "DATA/Archives/" +["sige:ArType"];

var destFolder = companyhome.childByNamePath(fName);

if ( destFolder )
   // Some debug info
   var d = companyhome.childByNamePath("debug.log");
   var c = d.content;
   c = c + "Ok : " + + "\n";
   d.content = c;;

   document.move(destFolder);  // <= crash here if not admin user
   // Some debug info
   var d = companyhome.childByNamePath("debug.log");
   var c = d.content;
   d.content = c + "Cannot get object for " + fName + "\n";;

function result()
   return 1;

The error is the following :
Une erreur système s'est produite pendant l'opération : 00140010 Failed to execute script 'workspace://SpacesStore/5c121eae-5458-4af1-8a76-ba059617385e': 00140009 Access refusé. Vous n'avez pas la permission de réaliser cette opération.
Translated : System error during operation : ……. : Access refused. You are not allowed to do this operation.

The log file says no more than the message above.

Thanks for your help.