I'm trying to build a saved search formula that sa...
# general
l
I'm trying to build a saved search formula that says if the invoice has no email/message attached or if the LATEST email recipient is not the same as the customer on the invoice, then show 0 else 1. I'm getting an invalid expression error. CASE WHEN {messages.internalid} IS NULL OR (MAX({messages.messagedate}) AND {messages.recipient} != (CASE WHEN {customermain.isperson} = 'F' THEN {customermain.entityid} || ' ' || {customer.companyname} ELSE {customermain.entityid} || ' ' || {customer.firstname} || ' ' || {customer.lastname} END)) THEN 0 ELSE 1 END
v
Not sure if you already solved it but it looks like you aren't evaluating anything with 'MAX({messages.messagedate})' but have an AND directly after it 🤔
l
That's definitely the issue. If I get rid of that, there is no error but the results are incorrect. What I need to do is to consider the MOST RECENT message which is why I used MAX.
v
Can you do 'MAX({messages.messagedate}) = {messages.messagedate}'? In my head this makes sense but I could see it being kind of wonky in practice