cancel
Showing results for 
Search instead for 
Did you mean: 

Passing parameter in action

thomasberment
Champ in-the-making
Champ in-the-making
Hi, I would like to know if it possible to pass a parameter to a script ?

I have this action :
 <!– Done-editing document –>
         <action id="done_editing_doc">
            <evaluator>org.alfresco.web.action.evaluator.DoneEditingDocEvaluator</evaluator>
            <label-id>done_editing</label-id>
         <script>/Company Home/Data Dictionary/Scripts/append copyright.js</script>
            <image>/images/icons/done_editing.gif</image>
            <action-listener>#{DoneEditingDialog.handle}</action-listener>   
            <params>
               <param name="id">#{actionContext.id}</param>
            <param name="ref">#{actionContext.nodeRef}</param>
            </params>
         </action>

But if I click, Alfresco says
Failed to execute script 'workspace://SpacesStore/1fddd771-ff46-43df-8918-b37d989ccd7d': 05170000 ReferenceError: "document" n'est pas défini (workspace://SpacesStore/1fddd771-ff46-43df-8918-b37d989ccd7d#1)
because document isn't knew …
I want pass the name of document to this script, but how ?
3 REPLIES 3

wimschreurs
Champ in-the-making
Champ in-the-making
Bonjour,

If you start a script from an Action context, you don't have access to the root objects - 'document' doesn't mean anything in this case.
You can use the following statements in your script to retrieve the parameter and the node:

var nodeRef = args["noderef"];
var mydocument = utils.getNodeFromString(nodeRef);

rafaelscg
Champ on-the-rise
Champ on-the-rise
Hi, return

I dont now if you could help me, but i'll try.
Im trying to create an action on document with Javascript. Im beginner programmer and i put the variables on my script, but, the node of SCRIPT DOCUMENT is return to me, and not the node of the document what i need. I think script is very easy to understand:

var nodeRef = args["noderef"];
var mydocument = utils.getNodeFromString(nodeRef);

var rootContest = companyhome.childByNamePath("Banco IBI/Sao Paulo/Intercambio/Processos de Contestacao");
var dataentrada = mydocument.properties["ibi:docdataentrada"];
var numcartao = mydocument.properties["ibi:docnumcartao"];
var numlote = mydocument.properties["ibi:docnumlote"];

var espacodataentrada = companyhome.childByNamePath("Banco IBI/Sao Paulo/Intercambio/Processos Aprovados/" + dataentrada);
var espaconumcartao = companyhome.childByNamePath("Banco IBI/Sao Paulo/Intercambio/Processos Aprovados/" + dataentrada + "/" + numcartao);
var espaconumlote = companyhome.childByNamePath("Banco IBI/Sao Paulo/Intercambio/Processos Aprovados/" + dataentrada + "/" + numcartao + "/" + numlote);


if (espacodataentrada == null){
   espacodataentrada = rootContest.createFolder(dataentrada);
}
if (espaconumcartao == null){
   espaconumcartao = espacodataentrada.createFolder("Teste");
}
if (espaconumlote == null){
   espaconumlote = espaconumcartao.createFolder(numlote);
}
if(espaconumlote != null){
      var movedoc = mydocument.move(espaconumlote);
}

I really need to make this, because this will resolve a big problem for our projects.
Thanks for help!

rafaelscg
Champ on-the-rise
Champ on-the-rise
The wiki help me with what i want to do. I just need use this lines to return the document:

var nodeRef = args["noderef"];
var node = search.findNode(nodeRef);

And get this from parameter:

<params>
   <param name="noderef">#{actionContext.nodeRef}</param>
</params>

Best regards,