CMDBuild Forum

CMDBuild Query Language, default value for unselected attribute

Hello CMDBuild team,

we have installed openMAINT 1.0 - 2.3.1.
We have a question about the CMDBuild Query Language:

In particular, we want to add a Filter to an attribute A of a Class.
The result should be based on the value of another attribute B of the same Class, chosen earlier by the user (same card).
We are happy we found a way to make this work, like this:

parseInt({client:B.Id})?'where Id in (/(SELECT "Id" FROM "TABLE" WHERE "Status"=\'A\' AND "Id"=(SELECT "COLUMN" FROM "OTHERTABLE" WHERE "Status"=\'A\' AND "Id"='+parseInt({client:B.Id})+' AND "Id" IS NOT NULL))/)':'where Id=0';

If the user does select something for attribute B, then we do have a value for parseInt({client:B.Id}) and we can filter.

However, if the user does not choose anything for attribute B, then our Filter cannot return the unfiltered choices for attribute A. In other words, the unfiltered A is what we want to show as choices for A if no B is selected.

It would be very convenient if you could tell us what the default value of parseInt({client:B.Id}) is, when the user leaves attribute B blank.


Thank you,
Dimitris

p.s. We already have read  the Administration manual.

1 Like

Hello Dimitris,

I think you just need to change the "else" part of your filter. Now you are asking the system to show cards with Id = 0 if B is not selected, so no cards are selected.
If you replace 'where Id=0' with '', you will have an empty filter on that filed if B is not selected, so it should show you all the unfiltered cards.
 
Hope this helps.
Kind regards
CMDBuild Team
 

Your suggestion worked perfectly!!!

 

Grazie mille!

Dimitris

Previously Tecnoteca wrote:
Hello Dimitris,
I think you just need to change the "else" part of your filter. Now you are asking the system to show cards with Id = 0 if B is not selected, so no cards are selected.
If you replace 'where Id=0' with '', you will have an empty filter on that filed if B is not selected, so it should show you all the unfiltered cards.
 
Hope this helps.
Kind regards
CMDBuild Team