This past week I had someone who is looking to use Case Comments in the Service Cloud, but wanted it to be listed as an Action in the Feed. I thought it would be a good use case of many different tools within Salesforce being used together. I am looking at possibly doing this with code and basing it off this post, but for now I figured that I’de show you how without code. Let me be clear that if you’re not using a Community that you can simply use the Internal Comments field instead without having to do anything. The only negative of going with this solution is that you’re not going to have your Case Comment Chatter Post visible until your Chatter feed is refreshed, but that is something that also happens with the Internal Comments field. The Case Comment record is visible instantly. And this works nicely with Salesforce1. With that said, let’s jump right in!
Automation Overview:
- Inputs for Case Comment received (Action)
- Process Builder triggered (Pass inputs into Visual Flow)
- Case Comment created in Flow
For this solution we have two different options in how we can do it architecturally:
- Record Create – Create new Custom Object
- Record Create – Create new Task Record
- Record Update – Use Custom Fields on Account/Opportunity
For me, because of not wanting to further complicate the Task Object and not wanting to add excess fields to the Case Object, I’m going to go with option 1 and create a new Custom Object.
How will we build this?
- Create the Case Comment Extension Object
- Create our Visual Flow to create the Case Comment
- Create our Process Builder to launch the Visual Flow
- Create our Action on the Case
For this solution we have two different options in how we can do it architecturally:
- Record Create – Create new Custom Object
- Record Create – Create new Task Record
- Record Update – Use Custom Fields on Account/Opportunity
For me, because of not wanting to further complicate the Task Object and not wanting to add excess fields to the Case Object, I’m going to go with option 1 and create a new Custom Object.
What fields do we need create in this Custom Object?
- Auto Number
- Case (Master-Detail)
- Comment (Long Text Area)
- Public (Checkbox) Note: this only applies if you have a Customer Community.
Let’s get our Flow created first since we can’t Activate the Process Builder without it (Setup | Create | Workflows & Approvals | Flows).
The first step is going to be grabbing our Record Create.
We now need to create the variables we will use to create the Case Comment.
Case Id
IsPrimary (This is a BOOLEAN, not Text)
CommentBody
Lets make sure everything is correctly mapped inside our Record Create.
Great! So lets hit OK and set this as our Starting Element.
Now lets drag in our Record Delete. This is so that we don’t add useless data into Salesforce.
Create a variable for the Record Id of the Custom Object record we just created, when our Action is used.
Map it in our Record Delete.
Connect the elements together to finish our Flow.
And lastly we want to Save and then Activate our Flow!
Fantastic! Now we need to setup our Process Builder that fires this Flow. So lets go create a new Process Builder for this. (Setup | Create | Workflows & Approvals | Process Builder)
We want the Process Builder to fire on our Custom Object that we created, Case Comment Extension, and we want it to fire only when a record is created.
We don’t need to set any criteria here, but to be safe let’s just make sure that we have a Case ID and Comment before proceeding.
Now we need to map the variables in our Flow to the Values in the Custom Object, using the Type Reference.
Hit Save, then Activate your Process Builder. Now, lets navigate to go create our Action.
Keep it on the default, Create a Record, and select Case Comment Extension (our Custom Object we created earlier).
Let’s make sure we turn off the Create Feed Item, so we don’t spam the Chatter Feed since the Case Comment itself will cause a Feed Item to be created. Also, make sure we add in a nice Success Message and custom Icon to make the action look sharp!
Remove the Case Field and drag Public and Comment into the Action’s Page Layout. Make sure you require the Comment field.
It will give you a small popup warning you about not having the Case field on the Layout, but you can ignore it and move on.
We now need to setup a Predefined Field Value for our Case field.
Set Case.Id to our custom Case field.
Now all that is left is for us to update our layout(s)!
And with that, lets take a look at the finished product!
Hi David,
Thank you for posting this article.
I am currently using the out-of-the-box ‘Internal Comments’ standard field, as part of a customized created ‘Update Case’ action, in my Case Feed.
I’m trying to understand how the solution explained in this article is different then the out-the-box solution.
I did see that the final resulting Action in this article has the ability to make a comment ‘Public’ (we are not using the Customer Portal so this is not a needed field for us), but wonder how this is different then simply adding the ‘Internal Comments’ to an existing Action.
Thanks again for keeping this Blog, which is priceless.
Ido.
LikeLike
Hey Ido,
Yes Internal Comments works great and sync’s to the Case Comments. You technically could use add that field Public to the Case and use it as the value you’re basing the logic off of. But, then you’ve got to query and get the Case Comment Id to update and mark as Public, which then changes the order of operations slightly.
Overall, yes, if you’re not using a Customer or Partner Community then you want to use the Internal Comments. I’ll make sure to spell that out further in my post, as this is more of a limitation around using it with an active Community.
Thanks!
David
LikeLike
Thanks for the reply David.
Looking forward to your next post around case feed. You have been super useful to us.
LikeLike
Hey David! I am getting an error when the record is created in the Flow:
An error occurred at element Create_Case_Comment (FlowRecordCreate).
INSERT — INSERT FAILED — ERRORS : (MALFORMED_ID) ParentId: id value of incorrect type: ””,
Flow Details
Flow Name: CaseCommentExtensionCreation
Type: Autolaunched Flow
Version: 2
Status: Active
Flow Interview Details
Interview Label: CaseCommentExtensionCreation 8/29/2016 9:45 AM
Current User: Alan Kinsley (00570000004kAvQ)
Start time: 8/29/2016 9:45 AM
Duration: 0 seconds
How the Interview Started
Alan Kinsley (00570000004kAvQ) started the flow interview.
RECORD CREATE: Create_Case_Comment
Create one CaseComment record where:
CommentBody = {!var2_CaseCommentBody} (null)
IsPublished = {!var_IsPublished} (null)
ParentId = {!var_CaseId} (null)
Result
Failed to create record.
________________________________________
Error Occurred: INSERT — INSERT FAILED — ERRORS : (MALFORMED_ID) ParentId: id value of incorrect type: ””,
LikeLike
Alan,
What is the Input/Output type for your variables? They all are listed as NULL, so I am assuming that you’re variables are set as Private and not Input Only or Input & Output. So right now you’re trying to create a Case Comment without a Case ID attached, which is causing that error.
That should be a change in your Flow as opposed to your PB (assuming the variables are mapped correctly there).
Thanks,
David
LikeLike
I got it to work! It was something I had configured wrong with the PB.
However, it is not creating a Feed Item now when I create a Case Comment using the Quick Actions. We want it to create a Feed Item.
LikeLike
Alright…The Case Comments are appearing in the Feed in the Sandbox. However, I pushed it to Prod and they are NOT showing up in the Feed in Production. I haven’t changed any settings between Sandbox and Prod. What can be causing this issue?
Thanks!
Alan
LikeLike
Alan,
By default that should be happening. Have you refreshed your view after you use it?
The Feed Item won’t show up until after that happens. You’re creating a Case Comment with your Action, and it should by default be creating a Feed Item in your Case Feed unless you have it filtered out your console for some reason.
LikeLike
Hey David,
Case comment notifications are not sent when the comment is created in Feed, via the Flow I created. However, they are being sent when created in the Detail view via the Case Comments Related List.
Do i need to add something to my flow?
Thanks!
LikeLike
The comment should create a feed item by itself. Are you sure the page has been reloaded? The Flow won’t automatically reload it the way it is currently setup in this post.
LikeLike