0 votes

Hello Efficy team,

I struggle to solve a simple problem.

I have a category in companies. The customer asked me to format some information and to show the information only when the field is different form zero and the customer have rights on the category. So I did a custom field :


        , $myfield$=`%%GetField('$FIELD$', category="COMP$CHIFFRES", nolabel=T)`
        , $value$=`%%GetField('$FIELD$', category='$CATG$')`
        , $display$=| €|


    <dt><%OnArgument(Argvalue='$value$',condition='case', value='', then=||, value=0, then=||, else=`<%LoadScript("CommonLibrary")%><%RunScript(formatCurrency, value='$value$')%> $display$ `)%></dt>

My code work as expected for a company were the category has been activated.

But if the category is not activated, it show "0".

I tried this :

 <dd><%OnArgument(Argvalue='$value$', condition='case', value='', then=||, value=0, then=||, else=|$myfield$|)%></dd>

But is show "0" again.

I did activate the option "displayed if not empty" in conficy :

enter image description here

How can I test if the category were activated ? I thought of an SQL query but it seams a bit overkill.

The client is in Efficy 10sp2+. If there is a solution in Efficy 11, this also good (the upgrade is planned).

Thanks in advance,


closed with the note: The solution of Kristof is currently the best. A suggestion has been made to the R&D
asked in Efficy/ Client side by (466 points)
closed by

1 Answer

+2 votes
Best answer

Hi Loic.

There is indeed a tag missing to detect the activation of a category. This gap can be easily solved by a serverscript.

Consider also reading my Category Forms manual in the Project Guides.There I refer to a serverjs module serverjs/functiontags/categories that exposes function ifCategoriesActive

It can be used like this:

<%RunScript(ifCategoriesActive, categories="DOCU$INVOICING", then="1", else="0")%>

FYI, this is the source code:

* Switch code based on the activated category
* usage example:
* <%RunScript(ifCategoriesActive, categories="DOCU$INVOICING", then="1", else="0")%>
function ifCategoriesActive() {
    var editId = Request.contextHandle,
        categories = Arguments.values("categories").split(";");

    var cntActive = 0;
    categories.forEach(function(category) {
        var dsCatg = Efficy.getCategoryDataSet(editId, category);
        if (dsCatg && !dsCatg.isEmpty) {

    return cntActive == categories.length ? Arguments.values("then") : Arguments.values("else");
answered by (7.2k points)
selected by
A suggestion has been made to the R&D. Thanks for the enlightenment.
1,226 questions
1,495 answers
328 users