2

I am trying to create a validation rule to lock down our original utm fields on leads after they are first populated.

Essentially I would like to prevent everyone (including our marketo sync user) but a 'system admin' to be able to update the fields below.

I think I have the Rule down for the most part, but I keep getting a syntax error "Missing ')'", please see below. Any help would be appreciated.

AND(
    $Profile.Name <> "System Administrator",
    ISCHANGED( OG_Lead_Source__c ),
    NOT(ISBLANK(PRIORVALUE( OG_Lead_Source__c )))
    ISCHANGED( OG_Lead_Medium__c ),
    NOT(ISBLANK(PRIORVALUE( OG_Lead_Medium__c )))
    ISCHANGED( OG_Lead_Campaign__c ),
    NOT(ISBLANK(PRIORVALUE( OG_Lead_Campaign__c )))
    ISCHANGED( OG_Lead_Content__c ),
    NOT(ISBLANK(PRIORVALUE( OG_Lead_Content__c )))
    ISCHANGED( OG_Lead_Term__c ),
    NOT(ISBLANK(PRIORVALUE( OG_Lead_Term__c )))
)
  • Note: I'd advise that you use five separate validation rules instead of just one rule. This will provide a better user experience, since you will then be able to attach the error to the correct field. – sfdcfox Jan 5 at 4:05
3

You're missing commas after each NOT(ISBLANK(PRIORVALUE(...))), but beyond that your validation rule isn't quite right.

This rule will only complain to the user if they try to edit all of your target fields. What you'd need here is to use some OR(), because I'd imagine that you want this validation rule to complain if any of your target fields are changed after being set for the first time.

This is probably what you're looking for

AND(
    $Profile.Name <> "System Administrator",
    OR(
        AND(
            ISCHANGED( OG_Lead_Source__c ),
            NOT(ISBLANK(PRIORVALUE( OG_Lead_Source__c )))
        ),
        AND(
            ISCHANGED( OG_Lead_Medium__c ),
            NOT(ISBLANK(PRIORVALUE( OG_Lead_Medium__c )))
        ),
        AND(
            ISCHANGED( OG_Lead_Campaign__c ),
            NOT(ISBLANK(PRIORVALUE( OG_Lead_Campaign__c )))
        ),
        AND(
            ISCHANGED( OG_Lead_Content__c ),
            NOT(ISBLANK(PRIORVALUE( OG_Lead_Content__c )))
        ),
        AND(
            ISCHANGED( OG_Lead_Term__c ),
            NOT(ISBLANK(PRIORVALUE( OG_Lead_Term__c )))
        )
    )
)

The outer AND() exempts your system admins
The nested OR() allows you to complain if any of the inner bits evaluate to true
The inner AND()s break each situation up into their logical groups (the check for OG_Lead_Source__c shouldn't have any impact on the check for OG_Lead_Medium__c, etc...)

  • +1 for posting literally the same validation rule logic as I did, within 3 seconds of each other :-p – Morgan Marchese Jan 4 at 17:31
  • 2
    @MorganMarchese great minds, I suppose. – Derek F Jan 4 at 17:31
3

You are trying to do ISCHANGED() and NOT(ISBLANK(PRIORVALUE())) at the same time without separating them by commas, you can't do that. Each of those are separate arguments. You should leverage the AND and OR logical operators to bundle conditions together.

In your case, you only want to throw the error if the value is changed AND the prior value was not empty, so you should be using the AND() operator, but I also (assume) that you want it to throw the error if ANY of those fields are changed after being populated, so you should also leverage the OR() operator

The following Validation Rule is UNTESTED (but might work), but either way it should give you an understanding of what an implementation of this might look like

AND(
    $Profile.Name <> "System Administrator",
    OR(
        AND(ISCHANGED(OG_Lead_Source__c),NOT(ISBLANK(PRIORVALUE(OG_Lead_Source__c)))),
        AND(ISCHANGED(OG_Lead_Medium__c),NOT(ISBLANK(PRIORVALUE(OG_Lead_Medium__c)))),
        AND(ISCHANGED(OG_Lead_Campaign__c),NOT(ISBLANK(PRIORVALUE(OG_Lead_Campaign__c)))),
        AND(ISCHANGED(OG_Lead_Content__c),NOT(ISBLANK(PRIORVALUE(OG_Lead_Content__c)))),
        AND(ISCHANGED(OG_Lead_Term__c),NOT(ISBLANK(PRIORVALUE(OG_Lead_Term__c))))
    )
)
1

Sometimes the literal error message you receive stems from a misunderstanding on the parser's part of the structure of your code due to a different error.

In this case, you're actually missing a number of commas, not parentheses. You need commas after each value in your AND() function. You are missing commas following your first four NOT(ISBLANK(PRIORVALUE())) clauses.

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.