ACSCE-5X practice question 7 of 15

What is the simplest way to call a custom Alfresco repository JavaScript extension from a content rule?

Full set: 87 questions
Answer options
A: Create a new custom action that calls my script, and bundle both the custom script and the custom action into an AMP.
B: Add the script to Data Dictionary/Scripts, then use the “Execute a Script” action to call it from the rule. Correct answer
C: Add a function called “executeAction” to the JavaScript and place it on the classpath. Alfresco Content Services will add it as a rule action.
D: Upload the script to the folder on which the rule action is applied, and name it “ruleScript” so Alfresco Content Services can find it.
Correct Answer:
B. Add the script to Data Dictionary/Scripts, then use the “Execute a Script” action to call it from the rule.
Explanation

The simplest and most direct method to execute a custom script from a content rule is by leveraging the built-in "Execute a Script" action. This standard action is designed to locate and run JavaScript files stored in a specific, predefined location within the repository: the Data Dictionary/Scripts folder. When configuring a rule in the user interface, this action provides a dropdown list of all available scripts from that folder. This approach requires no custom Java development, Spring configuration, or packaging into an AMP, making it the most straightforward option.

Why Incorrect

A. Creating a new custom action and bundling it into an AMP is a more complex, heavyweight development process, not the simplest way.
C. Placing a script on the classpath with a specific function name does not automatically register it as a new, selectable rule action in the UI.
D. The "Execute a Script" action is hard-coded to look in the Data Dictionary/Scripts folder, not the folder where the rule is applied.

References

1. Alfresco Content Services 5.2 Documentation, "Out-of-the-box actions": This official documentation lists the available actions for content rules. For the "Execute script" action, it states: "Executes a script against the content item. You select a script from the menu that contains all the scripts available in the Data Dictionary > Scripts folder."

Source: Alfresco Documentation, Alfresco Content Services 5.2, "Using rules > Out-of-the-box actions". (Specific section reference).

2. Alfresco Content Services 5.2 Documentation, "Repository-side JavaScript files": This section explains where to store repository-side JavaScript files for them to be accessible by features like rules. It specifies: "Store your scripts in the repository in Company Home > Data Dictionary > Scripts. The out-of-the-box rule action 'Execute a script' can then be used to run the script."

Source: Alfresco Documentation, Alfresco Content Services 5.2, "Developing > Customizing and Extending > Repository-side JavaScript > Repository-side JavaScript files". (Specific section reference).

Scroll to Top