2

I am a bit lost on how to complete this validation rule.

If a user chooses "Yes" from the picklist, I would like a reminder (error message) to appear at the bottom of the field advising them to check another object before continuing. I know this can be done with an apex trigger but I am not confident yet to create one.

IF(ISPICKVAL( $ObjectType.Plan__c.Fields.Uses_Transit__c , "YES")

Reminder (Error Message): Check the Current Fiscal Year IRS/DOL Limits for Annual and Monthly Limits. enter image description here

I am getting a syntax error. I am not sure what I am missing.

Thanks in advance.

  • The current error is for missing ')', however you are not using the correct syntax of the function here as well. – Dave Jul 9 '15 at 15:14
2

With an If statement, you need 3 values, the condition to test, a value if it's true, and a value if it's false. If what you're looking to find out is whether or not the value of that pickval is "yes", then just use:

ispickval(fielname,"Yes")
  • Thanks. I am a little confused on filename portion of the formula. I currently have (ISPICKVAL( $ObjectType.Plan__c.Fields.Uses_Transit__c , "Yes") ) – user22024 Jul 9 '15 at 17:05
  • I used (ISPICKVAL(Uses_Transit__c , "Yes") ) But, I now receive "Error: Invalid Data. Review all error messages below to correct your data" as well as my error message. Error: Check the Current Fiscal Year IRS/DOL Limits for Annual and Monthly Limits. I choose yes but the page will not save. – user22024 Jul 9 '15 at 17:13
  • I've read your exchange with @JennyB. It sounds as though you may want to rethink your logic/approach to using this field as an indicator that something isn't correct in the data from this related object. A validation rule doesn't seem to be the correct way to handle it. Some other business logic would seem to be in order. – crmprogdev Jul 9 '15 at 17:56
0

That error just means you are missing a closing parenthesis on one of your functions...

IF(ISPICKVAL( $ObjectType.Plan__c.Fields.Uses_Transit__c , "YES")  

IF() // should have an open and close
ISPICKVAL() // should have an open and close

but your formula is incomplete, an IF statement requires a result for when it is true and when it is false. Since you are creating a validation rule you really do not need the IF statement just the ISPICKVAL($ObjectType.Plan__c.Fields.Uses_Transit__c , "YES")

UPDATE: After reading your requirements again, I don't think a validation rule is what you are looking for because it will not be a warning it will be an error and not let the user continue. I would suggest using a formula to create a reminder on the screen or perhaps javascript to throw out a popup message.

  • Thank you Jenny. When I use (ISPICKVAL( $ObjectType.Plan__c.Fields.Uses_Transit__c , "YES") ) I get "Error: Incorrect parameter type for function 'ISPICKVAL()'. Expected Picklist, received Object" – user22024 Jul 9 '15 at 15:16
  • @SynthiaBeauvais Didn't notice the $ObjectType, use the formula insert field functionality to find the field to evaluate. – Jenny B Jul 9 '15 at 15:21
  • @SBeauvais34 updated my answer, I'm not sure using a validation rule will help you achieve your goal. – Jenny B Jul 9 '15 at 15:26
  • I was afraid of that. The field is not mandatory so I just need the error message to populate once the field is being used (Yes is chosen). Thank you. – user22024 Jul 9 '15 at 15:29
  • 1
    Nevermind. I used AND ( ISPICKVAL(Uses_Transit__c , "Yes"), ISBLANK( Transit_Annual_Limit__c ) ) I was able to place my error message and advised the user to fill in the appropriate fields. – user22024 Jul 10 '15 at 14:30

Your Answer

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