Show an user action button only when under a certain folder


I have created an user action button that needs to be displayed only for a document when under a certain folder and when the document is in “approved” state.

I cannot use the STARTSWITH within the query because while the folder name is defined e.g. say all folders named “test”, the path is not. The users have the right to modify the names of the folders within the path. Hence the query has to check for, at least, if the path has the word “Proposal” in it.

My condition goes like this

<rule grant="false">
    <condition>document.currentLifeCycleState != "approved"</condition>
    <condition>path NOT ILIKE '%test%"</condition>

However I am not getting the required result and the action button shows no matter what folder the document is in. The “approved” condition however works correctly.

I have tried the above conditions with options “OR” in a single line but even that does not give the desired results.

What am I doing wrong? Any solutions?

thanks in advance.

0 votes

1 answers



The NXQL in a condition of a filter is not permit.

When you want to make complex condition in your filter you should better use an EL expression to call a method from a Bean.

For example, in your xml contribution :

<rule grant="false">

With the method isPathContainsWord() looks like :

public boolean isPathContainsWord(String word) {
    DocumentModel currentDoc = navigationContext.getCurrentDocument();
    return currentDoc.getPathAsString().contains(word);

For more informations you can read the User Actions Documentation.

1 votes