If Statement in aggregate filter

Hello,

I have an web block with an boolean input parameter and depending on the value, I want to apply a filter. Something like this:

If (Requested, Event.EventStatusId=Entities.EventStatus.Approved and Event.EventStatusId=Entities.EventStatus.Requested, Event.EventStatusId=Entities.EventStatus.Approved)

It's not working and gives me "Invalid use of "Boolean" in Filter." 

I'm not understanding why. 

Statement seems correct.I placed the same statement within webblock and its not giving me any error in web block preparation.


That's strange... I don´t understand why it doesn´t work here...

What is the "Requested" variables data type?

Andres Moreno wrote:

What is the "Requested" variables data type?

Both of them are boolean.


Hi Andre,

can't help you with this problem, I tried little demo app and am able to use this filter, works as expected.  See attached oml, maybe you can spot the difference with what you are doing.

But I just wanted to add to this discussion, that I find the 'and' condition in the second part a bit odd, since a single event will probably not be both requested and approved at the same time.  You probably want this to be an or ?  Or am I reading this wrong ?

hope this helps,

Dorine


Edit : If I'm reading the requirement right : retrieve both requested and approved if parameter Requested is True, or else only retrieve approved

then that can be done with this filter, maybe that one will work for you :


Event.EventStatusId = Entities.EventStatus.Approved or Event.EventStatusId=Entities.EventStatus.Requested and InRequested

Wich version are you using? 

In OS10 I've got the same error, but in platform 11 it seems to work.

Eduardo Pires wrote:

Wich version are you using? 

In OS10 I've got the same error, but in platform 11 it seems to work.

Hi Eduardo.

I am using platform 10. So maybe that's the problem... need to find another way of doing this.


Dorine Boudry wrote:

Hi Andre,

can't help you with this problem, I tried little demo app and am able to use this filter, works as expected.  See attached oml, maybe you can spot the difference with what you are doing.

But I just wanted to add to this discussion, that I find the 'and' condition in the second part a bit odd, since a single event will probably not be both requested and approved at the same time.  You probably want this to be an or ?  Or am I reading this wrong ?

hope this helps,

Dorine


Edit : If I'm reading the requirement right : retrieve both requested and approved if parameter Requested is True, or else only retrieve approved

then that can be done with this filter, maybe that one will work for you :


Event.EventStatusId = Entities.EventStatus.Approved or Event.EventStatusId=Entities.EventStatus.Requested and InRequested

Hi Dorine,

yes I am using this filter to retrieve both requested and approved if parameter Requested is True or else only retrieve approved.


You can do something like this:

(Requested and (Event.EventStatusId=Entities.EventStatus.Approved and Event.EventStatusId=Entities.EventStatus.Requested)) or (not Requested and Event.EventStatusId=Entities.EventStatus.Approved)

André Vieira wrote:


Hi Dorine,

yes I am using this filter to retrieve both requested and approved if parameter Requested is True or else only retrieve approved.


So then filter as I am proposing should work  :


Event.EventStatusId = Entities.EventStatus.Approved 
or 
Event.EventStatusId=Entities.EventStatus.Requested and Requested

Hello Andre,

What is your use case? What do you want to filter?

As per my understanding of your problem,Before the preparation of web block is rendered assign this if condition to a variable and use that variable in the filter of aggregate

Hello Naren,

I have a checkbox in a screen assigned to a local variable (Requested, type boolean). And then I have a web block with that boolean as an input parameter. If the value is True, I want to show the Events that have the status Approved and Requested. If it's false only the Approved ones.

Solution

Hi André,

In version 10 you can not use boolean variables as condition without comparing them to a boolean value.So then you've to add that in your filter, Requested = True

Event.EventStatusId = Entities.EventStatus.Approved 
or 
Event.EventStatusId = Entities.EventStatus.Requested and Requested = True
Solution

You can add something like this :

If (Requested=True, Event.EventStatusId=Entities.EventStatus.Approved and Event.EventStatusId=Entities.EventStatus.Requested, Event.EventStatusId=Entities.EventStatus.Approved)

or suggested by Dorine 

If (Requested, Event.EventStatusId=Entities.EventStatus.Approved and Event.EventStatusId=Entities.EventStatus.Requested, Event.EventStatusId=Entities.EventStatus.Approved)

It is solved! Thank you all for your help.