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
RobBirdRobBird 

History Comment Validation

Hello there! I am trying to create a rule that will put a comment in the "History Comment" field of a Lead and a certain result is picked from a picklist.

 

For example: User selects "Left Message to Call" from a picklist, then in the History Comments it will show "10/9/2009: Left Messaage to Call-User Name"

 

Any thoughts?

 

Thank you!

mpannmpann

Do you mean Activity History? When you click "Log a call" on the lead record it wil create an activity in the activity history related list with the subject as one of the column. The user should write "Left Message to Call" in the subject of the Activity or you can add that Value to the combo list options.

 

 

RobBirdRobBird

We have a custom text field called "History Comments" that are used to log everything we have done with that Lead. The text added by the user depends on what the user talked about with the Lead. However, all of the leads have a Lead Result (No Answer, Left message to call, hung up, etc.) that is a picklist. So my thought is, if the user picks a certain Lead Result, a standard History Comment is placed.

 

For example, a user picks "Hung Up" as a Lead Result from the picklist, then saves the changes. Once that happens, a standard comment of "todays date-called Lead re: Internet issues, Lead hung up-user name".

 

Does that make sense?

mpannmpann

Hi Rob,

 

yes, that does make sense. I would say that this is not exactly best practice  :smileywink: but I'm sure there are reasons not to use activities. Here's what you should try:

 

Create a workflow rule:

Select "Evaluation Criteria = Every time a record is created or edited" and Formula as the evaluation criteria:

ISCHANGED (Status)

 

Then create a field update on your Lead field ("History_Comments__c" ?)

 

PRIORVALUE(Description)&BR()& TEXT(TODAY())&" - "& CASE ( Status , "Working - Contacted" , "Left Voicemail", "Did something")&" - "& $User.Username

 Instead of the line "Working - Contacted", "Left Voicemail", you should enter your lead statuses and the respective history comment. You can add as many lines here as you have Status entries. If unsure, check the help for the CASE function.

 

This will create a history comments entry each time the Lead Status changes. Conveniently, it simply adds a new line, without deleting the prvious comment.

 

You can restrict the the rule to only fire on certain statuses, if you want to.

 

Good luck. Let me know if you get stuck.


 

RobBirdRobBird

I tell ya, I really have issues with the rules and how they work. I really need some training on these. So in your rule:

 

PRIORVALUE(Description)&BR()&
TEXT(TODAY())&" - "&
CASE ( Status ,
"Working - Contacted" , "Left Voicemail",
"Did something")&" - "& $User.Username

 

If I am using this with Leads, do I replace "CASE ( Status..." with "LEAD (Status...?

mpannmpann

Hi Bob,

 

no, CASE is the function you need. The Field Update wizards asks you as the first step which object it should refer to, in your case: Leads.

 

I re-read your previous post and apologize. I missed that you have a custom picklist for results. Replace the workflow rule criteria with "ISCHANGED (Lead_Result__c)", as you want it to trigger when that changes and not the status. If this doesn't work, check the API name of your field Lead Result.

 

In the update action I used the standard lead status values from my developer org. Let's assume you have the values "No Answer, Left message to call, hung up" in your picklist, your history field is called History_Comments__c and your picklist is Lead_Result__c

This would be the code for the formula in your update action:

 

PRIORVALUE(History_Comments__c)&BR()& TEXT(TODAY())&" - "& CASE ( Lead_Result__c , "No Answer" , "Called - No answer", "Left message to call" , "Called - Left Voicemail", "Hung up" , "Called - Hung up", TEXT(Lead_Result__c))&" - "& $User.Username

 

 You see that the first text refers to the value in your picklist, whereas the second one is the text that will be inserted to the history comment field. Note that the last entry (TEXT(Lead_Result__c))  displays the picklist value, if the CASE function could not match any of the values on the left with the currently selected picklist value.

 

I hope this helps. You should check out the help and training videos as well as the resources on salesforce.com. 

 

RobBirdRobBird

When I try to use this formula (and just change the Field names), I get the following error:

 

Error: Incorrect parameter for function TEXT(). Expected Number, Date, DateTime, received Picklist

 

Here is how the formula looks that I am getting the error on:

 

PRIORVALUE(History_Comments__c)&BR()&
TEXT(TODAY())&" - "&
CASE ( Loan_Status__c ,
"No Answer" , "Called - No answer",
"Left message to call" , "Called - Left Voicemail",
"Hung up" , "Called - Hung up",
TEXT(Loan_Status__c))&" - "& $User.Username

 

Any thoughts?

mpannmpann

It depends on where you are using it. TEXT(picklist) works in formulas, valiation rules and field updates.

 

Could it be that you are using this formula in the workflow rule itself? If this is the case, I strongly recommend learning more about workflow rules, before attempting to implement this.

 

Once you understand how they work, you should have no trouble analyzing the code and put this rule with the field update in place.

 

If you don't want to get bogged down with customization issues, you may also want to look into getting some help from a consulting/remote admin side. Send me a PM if you would like me to recommend someone.