function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
salauncesalaunce 

Validation Help: Force Comments

I am trying to drive better adoption around having reps enter comments, if they made specific changes to 5 fields on an opportunity. This is only if they made a change to any or all these defined fields.

 

Defined 5 Fields - changes are made to any or all the fields

(Field_1)

(Field_2)

(Field_3)

(Field_4)
(Field_5)

 

Comment Fields - This is field that needs to updated

(Oppty_Comments)

 

Lets say the rep makes a change to field 2 and 3, but failed to enter comments before attempting to save the record. How would I write that in a validation so when the user attempts to save the record, it will throw up an error for guidance.

 

I almost forgot....this applies to any time these fields were changed. That means, if I edited any of these fields on Monday for the first time and got the error msg and completed the comments field...and then came back on Wednesday and edited any of them...the comments field would not be be blank, but I still need them to get the same error to update that fields again with the most recent information.  Hope that mades senses...the net of it is..whether the comments fields is blank or has a value they still should get the error msg if they made a change to defined fields.

 

Any help would be tremendously appreciated.

 

Kind regards,

Simply Novice

Message Edited by salaunce on 02-26-2010 01:52 PM
Best Answer chosen by Admin (Salesforce Developers) 
Amber NeillAmber Neill

Try using OR instead of AND:

AND(OR(ISCHANGED(Field_1), ISCHANGED(Field_2), ISCHANGED(Field_3), ISCHANGED(Field_4), ISCHANGED(Field_5)), NOT(ISCHANGED(Comments))

 

 

That'll catch a change in any field and require a change in the comments field.

 

Sorry, my brain must have left early for the weekend! :-)

Amber

All Answers

Amber NeillAmber Neill

You're probably going to want to use the ISCHANGED() function.

The formula would look something like this:

 

AND(ISCHANGED(Field_1), ISCHANGED(Field_2), ISCHANGED(Field_3), ISCHANGED(Field_4), ISCHANGED(Field_5), NOT(ISCHANGED(Comments))

 

I havne't checked the syntax, but that should work.

Good luck!
Amber

salauncesalaunce

I entered it and recieved a syntax error, so I added an additonal ")" to the end and no errors were found. It is marked active, but when I went into an oppty it still allowed me to make the any or all changes to these fields and allowed me to save it with no error message and no comments.  :smileysad:

 

The other thing that should be part of this....is not when the record is created...only when it's edited.

 

Thought? I really need to nail this one because we are doing a mass clean up this weekend and this validation will be extremely helpful to the sales leaders.

Still_WelshStill_Welsh

Amber's validation is correct , but all 5 fields must change for it to kick in. You might want to create a  validation rule for each of the five fields if you want this to fire if only 1 field is changed

 

AND( ISCHANGED( field1 ) , NOT( ISCHANGED( comments ) ) )

Amber NeillAmber Neill

Try using OR instead of AND:

AND(OR(ISCHANGED(Field_1), ISCHANGED(Field_2), ISCHANGED(Field_3), ISCHANGED(Field_4), ISCHANGED(Field_5)), NOT(ISCHANGED(Comments))

 

 

That'll catch a change in any field and require a change in the comments field.

 

Sorry, my brain must have left early for the weekend! :-)

Amber

This was selected as the best answer
salauncesalaunce

U ROCK!!  It worked and worked well!

 

Many thanks!

salauncesalaunce

Amber,

 

One small caveat to my validation that came up today.....this should only impact records that have the Division set to SSCDivision is a picklist. I attempted to  make a change to the rule you helped me with, but the validation error appears no matter what division is selectedDid I write this correctly? (see below) The formula is not throwing up any errors through the syntax check, but it still is not working correctly.

 

AND(OR(ISPICKVAL( S_Division__c , "SSC"),ISCHANGED(CloseDate), ISCHANGED(Estimated_Contract_Value__c), ISCHANGED(Term_Number_of_Months1__c), ISCHANGED(Bill_Rate1__c), ISCHANGED(Number_of_Resources1__c )), NOT(ISCHANGED(Opportunity_Change_Comments__c)))

 

Any help would be tremendously appreciated.

 

 

Amber NeillAmber Neill

Try this:

 

AND(OR(ISCHANGED(Field_1), ISCHANGED(Field_2), ISCHANGED(Field_3), ISCHANGED(Field_4), ISCHANGED(Field_5)), NOT(ISCHANGED(Comments)), ISPICKVAL( S_Division__c , "SSC"))

 

I think that'll work....

Good luck,

Amber

salauncesalaunce

Amber,

 

It worked like a charm! Many thanks for your prompt response. You make life easy! :smileywink:

Amber NeillAmber Neill
I'm printing out this thread and handing it to my boss with a red ribbon around it!  :-)
Thanks for the kudos!
Amber