Hi everyone,

I have an aggregate that's supposed to return a shopping cart.
I have two entities, Customer and AnonymousCustomer, that have ShoppingCart Identifiers in them.

Now, I need the aggregate to check whether the customer is registered and if yes, it should filter using the Customer entity and if not, it should filter using the AnonymousCustomer entity.

This is the filter I've been trying (and several variations):

ShoppingCart.Id = If(GetUserId() <> NullIdentifier(),
GetCustomer(GetUserId()).Customer.ShoppingCartId,
GetAnonymousCustomer(Client.AnonymousCustomerId).AnonymousCustomer.ShoppingCartId)


Sadly, it doesn't seem to be working.
When I try to view my shopping cart as a registered user, an error pops up saying that the AnonymousCustomer with ID 0 has not been found. When I try to view my shopping cart as an anonymous user, the error says that the Customer with ID 0 has not been found.

Can anyone help?
Thanks in advance.

Hi,

If it is possible, can you please share you oml here so that I can look into the queries & filter that you are using. It will give more clarity in understanding your problem. 

Thanks,

Sachin

Processing Upload...

Sachin Mahawar wrote:

Hi,

If it is possible, can you please share you oml here so that I can look into the queries & filter that you are using. It will give more clarity in understanding your problem. 

Thanks,

Sachin

 Hi,

I'm quite new to OutSystems, but I hope this works?

Thanks

 

Solution

From my experience you don't that kind of filtering in the aggregate itself but outside? Create an variable of ShoppingCardId and set it to the correct value before calling the aggregate. Use this variable in the filter instead of your if statement.

Greetings,

Vincent

Solution

Vincent Koning wrote:

From my experience you don't that kind of filtering in the aggregate itself but outside? Create an variable of ShoppingCardId and set it to the correct value before calling the aggregate. Use this variable in the filter instead of your if statement.

Greetings,

Vincent

 Thank you so much, that worked. I'd also sent an email to my team lead as work and he suggested the same thing.