2

I am struggling with this validation rule, and I cannot figure out why.

and(
not(isblank(Submission__c)), 
isblank(Submission_Comment__c))

Submission is a currency field and Submission Comment is a text field.

I want to throw an error when someone enters a submission value (be it positive or negative), but does not have a comment entered. The above validation rule should be giving me this result (at least in my mind), but the record is still saving if I add a submission and leave the comment field blank. It also saves if I fill in something in the comment field.

Any help on this would be much appreciated.

Here is what I am doing with this. I have a long text area that will be used to track history of these 2 fields. Whenever someone enters a submission, I have a rule that will take the submission value, and add it to a rolling total field. We have been using the normal field history until now. But, recently, we have had an increase in the number of customers asking why their submissions are higher than expected. Instead of people having to look back through emails and other correspondence over the past year, the new comment field will allow us to track notes and comments about the submission so that we don't have to spend as much time researching these requests. Nothing has been entered incorrectly so far, so our normal process is working great. I just need to reduce the research time that has increased over the past few months.

5
  • 2
    This syntax throws a validation error as expected for me, using a Currency field and a Text field... Jan 5, 2016 at 16:02
  • Thank you, Brian. That tells me that the error is somewhere else, then. Possibly with my rule copying the data to the new history field. I have spent an hour looking at and modifying this validation rule because the new process is not working as I expected.
    – smckitrick
    Jan 5, 2016 at 16:10
  • What is exactly the error you're getting? Is the validation rule compiling OK in your object? If it's compiling OK I would suggest testing this with a few unit tests, whereby you create an object, give different values to Submission__c and Submission_Comment__c and check that you get DML errors when you expect them
    – mkorman
    Jan 5, 2016 at 16:13
  • 1
    Thank you @BrianMansfield. This pointed me to look at my copy rule. The copy rule was not looking at the comment field (since I was expecting the validation rule to do that). When I added the comment field to my copy rule conditions, the new validation rule worked as expected.
    – smckitrick
    Jan 5, 2016 at 16:21
  • please post your solution to benefit the community
    – cropredy
    Jan 7, 2016 at 6:11

1 Answer 1

1

The problem actually lied with one of my other rules, and not the validation rule at all. I built the validation rule last, since I needed to make sure that everything else was working properly first. When setting up the rule to copy my currency and text fields, my copy rule was working just fine. However, because of everything that was being updated, the copy rule was ignoring the validation rule. In order to fix this issue, I had to put another condition in my copy rule that the submission comment had to not be blank. Once I did that, everything else worked.

If anyone else has a similar issue, check your workflow rules and/or triggers that touch either of these fields. Disable things if you need to in order to verify where the issue lies.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .