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
tywalker2276tywalker2276 

Workflow or Trigger creation

I am tyring to figure out how to create a custom filed (in the Case section) say "Latest Case Comment DateTime" using either a workflow or trigger to get this field  to populated with the creation date of the latest comment created/made.  Any ideas or suggestions would be much appreciated.

 

Thank you!

 

Tyler

Best Answer chosen by Admin (Salesforce Developers) 
SwarnasankhaSwarnasankha

The approach would have worked but unfortunately SFDC does not allow us to create fields on the Case Comment object.

 

Alternatively, we could have a Text Area field created on the Case object and have a workflow populate the value with the content of every Comment that is added to the case. In this case however, the Workflow will be overwriting the existing value with the new value and the value will always be the same as the content of the latest comment. Therefore, in your report, all you would need to display is the additional field created to capture the Case Comment Value.

 

Perform the following steps for creating the Field on Cases:

 

  1. Click on Setup-->App Setup-->Customize-->Cases-->Fields-->New
  2. Select the Field Type as Text Area (Long) and click Next
  3. Set the Field Label as 'Latest Comment Details' and set the Visible Lines to 5 or a number of your choice and click Next
  4. Select the Profiles for which you would like the field to be visible and click Next
  5. Select the Pagelayouts to which you would like the field to be added and click Save

 

 

Perform the following steps for creating the Workflow to populate the Field on Cases:

 

  1. Scroll Down and click on Create-->Workflow & Approvals-->Workflow Rules-->New Rule
  2. Select the object as 'Case Comment' and click Next
  3. Give the Rule a Name
  4. For Evaluation Criteria, select 'Only when a record is created'
  5. For Rule Criteria select 'criteria is met' followed by Field as 'Case Comment: Body', Operator as 'not equal to' but leave the Value as empty
  6. Click on 'Save & Next'
  7. Click on Add Workflow Action-->New Field Update
  8. Set a Name for the Field Update and leave the 'Protected Component' checkbox as unchecked
  9. For 'Field to Update', select Case followed by 'Latest Comments Details' from below Custom Fields
  10. Under Text options, select 'Use a formula to set the new value' and click on 'Show Fomula Editor'
  11. Click on Insert Field-->Body-->Insert. The type in box should have a value like CommentBody
  12. Click on Save followed by Done followed by Activate

 

After completing the Field Creation and Workflow Creation, add the field to the Case Report.

 

Point to Note - For all the closed cases or existing cases (until a new comment is added), the field named 'Latest Comment Details' will remain blank unless you manually decide to populate the value for the field for the relevant cases.

 

Hope this helps.

 

All Answers

BA_AdminBA_Admin

As per my understanding if you want to create a field go to case object from setup and create a new customfield, can you be in more detail why you want to use this workflow rule

tywalker2276tywalker2276

Whenever I comment on a case that I am working on it creates a new record that shows up in my cases report.  So depending on the case, it could have 20+ comments and thus multiple records associated with the case. I am looking for a way to be able to run a report on all of my cases where just the most recent comment shows up for each case as opposed to every comment showing up on every case.  This makes my report extremely long.

 

Another contributor suggested I try the following:

 

1. Create a field in case say "Latest Case Comment DateTime" and using either a workflow or trigger get this field populated with the creation date of the latest comment created/made.

 

2. Create a formula field say "IsLatest" at the case comment level which is set to true if  Latest Case Comment DateTime and case Comment created datetime is equal.

 

3. Now create a report on case object , select case comment as a field / column to be display and in filter criteria set the filter to IsLatest is set to true.

 

Is this the best way to accomplish this?  Or do you have any other ideas that would be easier?

 

Thanks for all of your help!

 

Tyler

SwarnasankhaSwarnasankha

The approach would have worked but unfortunately SFDC does not allow us to create fields on the Case Comment object.

 

Alternatively, we could have a Text Area field created on the Case object and have a workflow populate the value with the content of every Comment that is added to the case. In this case however, the Workflow will be overwriting the existing value with the new value and the value will always be the same as the content of the latest comment. Therefore, in your report, all you would need to display is the additional field created to capture the Case Comment Value.

 

Perform the following steps for creating the Field on Cases:

 

  1. Click on Setup-->App Setup-->Customize-->Cases-->Fields-->New
  2. Select the Field Type as Text Area (Long) and click Next
  3. Set the Field Label as 'Latest Comment Details' and set the Visible Lines to 5 or a number of your choice and click Next
  4. Select the Profiles for which you would like the field to be visible and click Next
  5. Select the Pagelayouts to which you would like the field to be added and click Save

 

 

Perform the following steps for creating the Workflow to populate the Field on Cases:

 

  1. Scroll Down and click on Create-->Workflow & Approvals-->Workflow Rules-->New Rule
  2. Select the object as 'Case Comment' and click Next
  3. Give the Rule a Name
  4. For Evaluation Criteria, select 'Only when a record is created'
  5. For Rule Criteria select 'criteria is met' followed by Field as 'Case Comment: Body', Operator as 'not equal to' but leave the Value as empty
  6. Click on 'Save & Next'
  7. Click on Add Workflow Action-->New Field Update
  8. Set a Name for the Field Update and leave the 'Protected Component' checkbox as unchecked
  9. For 'Field to Update', select Case followed by 'Latest Comments Details' from below Custom Fields
  10. Under Text options, select 'Use a formula to set the new value' and click on 'Show Fomula Editor'
  11. Click on Insert Field-->Body-->Insert. The type in box should have a value like CommentBody
  12. Click on Save followed by Done followed by Activate

 

After completing the Field Creation and Workflow Creation, add the field to the Case Report.

 

Point to Note - For all the closed cases or existing cases (until a new comment is added), the field named 'Latest Comment Details' will remain blank unless you manually decide to populate the value for the field for the relevant cases.

 

Hope this helps.

 

This was selected as the best answer