have an issue with this below formula, cant seem to find the root cause. The error says Error: Syntax error. Extra ','

If(TEXT(Test.Cold.Type__c) = '' || ISPICKVAL(Sale__r.Test__c, 'Sold') || TEXT(Test.Cold.Type_Set__c) = ''),0,1)

Here the first Text(Test.Cold.Type__C) is a picklist field and TEXT(Test.Cold.Type_Set__c) is a text field. I got this error when I added the last condition.

EDIT - Coming back to this again, what could be the reason for the first condition not to work when adding the last condition. I am not sure how to get out of this frustrating issue - If I just do If(TEXT(Test.Cold.Type__c) = '' || ISPICKVAL(Sale__r.Test__c, 'Sold'),0,1) it works, but when I add the third condition which is (Test.Cold.Type_Set__c='') the first one does not work. I guess I have tried my best so far.

  • 2
    Strongly suggest against using ||. Usage of OR instead makes the entire experience more consistent and therefore easier to avoid this sort of error.
    – Adrian Larson
    Sep 13 '21 at 19:46

You in fact have an extra parenthesis. As is often the case, syntax errors in your code may lead to error messages that don't quite make sense, because your code cannot actually be parsed.

    TEXT(Test.Cold.Type__c) = '' 
    || ISPICKVAL(Sale__r.Test__c, 'Sold') 
    || TEXT(Test.Cold.Type_Set__c) = ''
),0,1) <== Here's the problem - that first paren closes the IF()
  • 5
    and breaking formulas onto separate lines, indenting like you would in code (treating parenthesis like they were curly braces in code) as David has done here, really does help make it easier to see syntax errors. I'd go so far to say that doing this is the first step everyone should take when trying to diagnose/debug formulas in Salesforce.
    – Derek F
    Sep 13 '21 at 19:10
  • Thanks David Reed. I was actually looking for the extra comma, all the time.
    – sumchans
    Sep 13 '21 at 22:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.