cancel
Showing results for 
Search instead for 
Did you mean: 

How can I invoke an action from another action?

bishop_8870
Champ in-the-making
Champ in-the-making

Hi,

How can I invoke an action from another action?

I have an action that extracts metadata from a specific file, another action change type of document in reference to a name.

If a name of this file (A) is the same of another file in another directory, file B ( different file but same name)  an existing action must be started on file B.

Is it possible?

If yes, how to.

Thanks

1 ACCEPTED ANSWER

jpotts
World-Class Innovator
World-Class Innovator

Some additional specifics, such as where you are executing the action, what language you wrote the action in, etc., would be helpful, as well as what you have tried so far and any problems you've run into.

But, I will answer assuming you are talking about a rule action. One way to execute any number of actions from a rule is to configure your rule to execute JavaScript. Then, from JavaScript you can invoke as many actions you want on any objects you want.

Here's a little JavaScript snippet I pulled from the docs that shows how to execute an action from JavaScript:

var myCopyAction = actions.create("my-copy-action");
myCopyAction
.parameters["destination_folder"] = companyhome;
myCopyAction
.parameters["destination_name"] = "Copy of " + document.name;
myCopyAction
.execute(document);

In this case, the "document" variable is automatically populated by Alfresco when it invokes the rule. But you could do a search to get another object or whatever you need to, then you could set up as many actions as you want and call execute on those objects.

View answer in original post

2 REPLIES 2

mrks_js1
Star Contributor
Star Contributor

by action you mean an action that is being run upon a configured folder-rule?

you can run a script at the end of execution of a rule.

jpotts
World-Class Innovator
World-Class Innovator

Some additional specifics, such as where you are executing the action, what language you wrote the action in, etc., would be helpful, as well as what you have tried so far and any problems you've run into.

But, I will answer assuming you are talking about a rule action. One way to execute any number of actions from a rule is to configure your rule to execute JavaScript. Then, from JavaScript you can invoke as many actions you want on any objects you want.

Here's a little JavaScript snippet I pulled from the docs that shows how to execute an action from JavaScript:

var myCopyAction = actions.create("my-copy-action");
myCopyAction
.parameters["destination_folder"] = companyhome;
myCopyAction
.parameters["destination_name"] = "Copy of " + document.name;
myCopyAction
.execute(document);

In this case, the "document" variable is automatically populated by Alfresco when it invokes the rule. But you could do a search to get another object or whatever you need to, then you could set up as many actions as you want and call execute on those objects.