5
AND
(Sync_to_system__c
,OR(CONTAINS(Job_Name__c , '\\')
,CONTAINS(Job_Name__c , '/')
,CONTAINS(Job_Name__c , ':')
,CONTAINS(Job_Name__c , '<')
,CONTAINS(Job_Name__c , '>')
,CONTAINS(Job_Name__c , '|')
,CONTAINS(Job_Name__c , '*')
,CONTAINS(Job_Name__c , '?')
,CONTAINS(Job_Name__c , '+')
,CONTAINS(Job_Number__c '#')
,CONTAINS(Job_Name__c , '"')
,BEGINS(Job_Name__c, ' ')
,(RIGHT(Job_Name__c, 1)=' ')
,(RIGHT(Job_Name__c, 1)='.')))

Error: Syntax error. Missing ')'

I must be missing something really obvious but i put it into notepad++ and all the )'s look like they line up just fine,

Sync_to_system__c is a checkbox so I want to check that the box is checked and the job name has something like these.

4
  • You're missing a comma in CONTAINS(Job_Number__c '#'). Missing commas typically result in that misleading error about the parenthesis. Oct 6 at 16:43
  • @DavidCheng omg thankyou i knew it was somethign stupid thatt i missed
    – Tim Willis
    Oct 6 at 16:44
  • To anyone who wants to downvote this... don't. It's a perfectly valid question, well formatted and reproducible. Oct 6 at 16:46
  • If it's a Validation Rule, you should really just use REGEX.
    – Adrian Larson
    Oct 6 at 17:00
6

You are missing a , at Job_Number__c

,CONTAINS(Job_Number__c '#') 

Should be

,CONTAINS(Job_Number__c, '#')
5

Treating validation formulas like they were normal code and applying indentation tends to really help out on issues like this.

Doing that would look like this

AND(
    Sync_to_system__c,
    OR(
        CONTAINS(Job_Name__c , '\\'),
        CONTAINS(Job_Name__c , '/'),
        CONTAINS(Job_Name__c , ':'),
        CONTAINS(Job_Name__c , '<'),
        CONTAINS(Job_Name__c , '>'),
        CONTAINS(Job_Name__c , '|'),
        CONTAINS(Job_Name__c , '*'),
        CONTAINS(Job_Name__c , '?'),
        CONTAINS(Job_Name__c , '+'),
        CONTAINS(Job_Number__c '#'),
        CONTAINS(Job_Name__c , '"'),
        BEGINS(Job_Name__c, ' '),
        (
            RIGHT(Job_Name__c, 1) = ' '
        ),
        (
            RIGHT(Job_Name__c, 1) = '.'
        )
    )
)

That doesn't seem to indicate anything wrong with parenthesis, but there is an issue with the CONTAINS(Job_Number__c '#'), part.

You're missing a comma in between the arguments to that call to CONTAINS. It's true that it's not a parenthesis, but syntax errors in formulas have a tendency to cascade to generate other issues in the end.

1
  • 2
    also worth noting that when I plugged this into a validation rule in a sandbox of mine (replacing the fields with ones that I actually had), the check syntax button did highlight the bit of the formula that was the issue('#')
    – Derek F
    Oct 6 at 16:49
3

You can heavily optimize this code with REGEX, not to mention some of your conditions are nonsensical, specifically, a field cannot start with or end with a space character. Here's a revised version:

Sync_to_system__c && REGEX(Job_Name__c, '(.*(\\.$))|(.*[\\/:<>|*?+#].*)')
2
  • thanks I will test this out
    – Tim Willis
    Oct 6 at 16:58
  • Main reason I don't use regex much in validation rules is because they are a strange variant of their own and very hard to debug. Oct 7 at 17:22
0

AND( Sync_to_system__c, OR( CONTAINS(Job_Name__c , '\'), CONTAINS(Job_Name__c , '/'), CONTAINS(Job_Name__c , ':'), CONTAINS(Job_Name__c , '<'), CONTAINS(Job_Name__c , '>'), ,CONTAINS(Job_Name__c , '|'), CONTAINS(Job_Name__c , '*'), CONTAINS(Job_Name__c , '?'), ,CONTAINS(Job_Name__c , '+'), CONTAINS(Job_Number__c '#'), CONTAINS(Job_Name__c , '"'), BEGINS(Job_Name__c, ' '), RIGHT(Job_Name__c, 1)=' ', RIGHT(Job_Name__c, 1)='.' ) )

0

Yikes! Well that looked hideous... but it my defense I wrote it using my phone

Try this

AND( 
Sync_to_system__c, 
OR( 
CONTAINS(Job_Name__c , '\'), 
CONTAINS(Job_Name__c , '/'), 
CONTAINS(Job_Name__c , ':'), 
CONTAINS(Job_Name__c , '<'), 
CONTAINS(Job_Name__c , '>'), 
CONTAINS(Job_Name__c , '|'), 
CONTAINS(Job_Name__c , '*'), 
CONTAINS(Job_Name__c , '?'),
CONTAINS(Job_Name__c , '+'), 
CONTAINS(Job_Number__c '#'), 
CONTAINS(Job_Name__c , '"'), 
BEGINS(Job_Name__c, ' '), 
RIGHT(Job_Name__c, 1)=' ', 
RIGHT(Job_Name__c, 1)='.' 
))
1
  • 1) You should have edited your original answer rather than post an additional answer, so you should now delete one of them. If both of your answers are not the same, you can make a note in one answer as to their differences. 2) Your answer will give the same error as the original because it contains the same syntax issue [see both Casper Harmer's and Derek F's answers]. It appears that all you did was move the commas in the OPs code from the beginning of the line to the end of the previous line. This makes no functional difference - only aesthetic difference.
    – Moonpie
    Oct 7 at 13:19

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.