Maikman83
Occasional Observer

rule to check count of db query

Jump to solution

Hello everyone,

is it possible to define a rule that checks the count of a db query and when the query count is 0 something can be applied?

E.g:

<RULE>
    <WITH>
        <NOT>
            <EQUAL>
                <PROPERTY source="count" name="db.query"/>
                <NUMBER>0</NUMBER>
            </EQUAL >
        </NOT>
    </WITH>
    <DO>
        <PROPERTY name="VISIBLE" source="field_that_should_be_hided"/>
    </DO>
</RULE>

 

I mean, it would be sufficient to check how many possible entries are in list fields like CMS_INPUT_LIST, but I don't find any fitting property (e.g. SIZE only returns the values that are selected by the user).

Alternative it would be possible to create a query that returns the count of the db query, put that value in an input field and use that value. But I also didn't find a way to create a query that returns only the count.

Best, Maik

0 Kudos
1 Solution

Accepted Solutions
hoebbel
Crownpeak employee

Dear Maik,

to solve the problem, you need a self-implemented service (FirstSpirit module) that provides the corresponding information (how many records would a corresponding query return). You can then query this service in a rule and react to the return value. You can find more information here:

<SCHEDULE/> Asynchronous rule execution 

Best regards
Holger

View solution in original post

2 Replies
hoebbel
Crownpeak employee

Dear Maik,

to solve the problem, you need a self-implemented service (FirstSpirit module) that provides the corresponding information (how many records would a corresponding query return). You can then query this service in a rule and react to the return value. You can find more information here:

<SCHEDULE/> Asynchronous rule execution 

Best regards
Holger

Maikman83
Occasional Observer

Hi Hoebbel,

thank you for your response.

Looks like a loot of steps for that small outcome.

But we will keep that in mind and try it when it's necessary.

Best, Maik

0 Kudos