[SalesForce] The formula expression is invalid: Syntax error. Missing ‘)’ Help Please

When trying to save the below formula I get this error:

The formula expression is invalid: Syntax error. Missing ')' Help Please

Why do I get this error? How can I fix it?

AND(
          IF ( ISBLANK( [Case].ContactId) , false,
          AND( ![Case].Contact.CSATOptOut__c,
                   OR( ISNULL(Contact.CSAT_Date__c ), true,
                   Contact.CSAT_Date__c  <= TODAY() -5 ),              
                   OR(
                       RecordTypeId = 0128E0000009Fd5QAE,
                       ISPICKVAL( Origin, "Telefon", "Chat" )
                   ),
                   ISBLANK( Contact.MemberInGroup__c, false ),
                   ISPICKVAL( Status, "Avslutat" ),
                   OwnerId <= "NatterBox",
                   OwnerId <= "API-User Api-User",
                   NOT( ISPICKVAL( CaseReason, "Inget svar" )),
                   Contact.CreatedDate <= NOW()       
          )
        )
        )

Best Answer

There are quite a few errors in your formula

  • You are not passing the second parameter for the AND operator. AND operator needs at least 2 values. (Top most AND)
  • You are using ISPICKVAL with 3 parameters whereas it takes only two
  • You are comparing OwnerId field with <= operator, I think it should be either == or !=
  • OwnerId is the Id field, so it will contain the Id and not Name, rather you will have to compare with Owner.Name
  • You are missing the quotes on RecordTypeId

The error you are getting is because of the first point i.e. if you don't have anything else to pass to AND operator, remove that operator or else pass the other value.

On solving this issue, you will get the remaining errors which I mentioned above which will help you fix this.

Related Topic