Help updating custom field based on last chatter item (comment) on Account object using process builder - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Jordan HoldsworthJordan Holdsworth 

Help updating custom field based on last chatter item (comment) on Account object using process builder

Hi,

I have set up a field on Account called "last case comment". The point of this is so we can run a report and include the field to get the last chatter comment that was posted on the account feed. Our sales team use the chatter feed on the account page to share their updates, but we can't then include their latest comment in reports.

I have created a process builder based on the object "feed item", the criteria is then whenever the "feeditem.created date" is changed and boolean = true, then it initiates an action. The action is a quick action I set up in the object "Account" which is a record update action.

Then I have to enter the criteria for the action, automatically one field is filled in and cannot be edited called "related record ID", as I don't want to change the actual account record I just said to update it with the Parent Record - Account - Master Record ID, so it just cancels itself out I think. The next field I added was to update the field "latest case comment" with the field reference "feeditem.body".

This is quite complicated and so far doesn't work, if anyone has any suggestions I would highly appreciate it. I have included screenshots below. Thanks.

User-added imageUser-added image
Best Answer chosen by Jordan Holdsworth
Tom HoffmanTom Hoffman
Hi Jordan - see below - just tested & it works

User-added image
ParentID starts with 001 & Body is null boolean false
User-added image

User-added image
Update Parent ID - I updated the generic description field with the feed body. 

My Chatter Post Below...I really need to change my profile picture in my dev org.
User-added image

And the result on the account record:
User-added image
I have another process flow in place that tags my comments with initials and dates...so your results will be a little different. 

 

All Answers

Pruthvi Raj KankunthalaPruthvi Raj Kankunthala
@Jordan: Instead of "FeedItem" , can you try "FeedComment" object and field "CommentBody". FeedItem represents the entire Feed whereas FeedComment is the child of FeedItem where you will be having the comments.
Tom HoffmanTom Hoffman
Hi Jordan - see below - just tested & it works

User-added image
ParentID starts with 001 & Body is null boolean false
User-added image

User-added image
Update Parent ID - I updated the generic description field with the feed body. 

My Chatter Post Below...I really need to change my profile picture in my dev org.
User-added image

And the result on the account record:
User-added image
I have another process flow in place that tags my comments with initials and dates...so your results will be a little different. 

 
This was selected as the best answer
Jordan HoldsworthJordan Holdsworth
Hi Thomas,

Thank you very much for your answer. I am half way through it now but I have an additional question if you would be so kind to help me with.

In terms of the action to select, I have created a quick action in the object Account (where the field I want to update is located). This action is a Standard Label Type - Update [Record], however when I select this, it won't let me select which field to update? It auto populates field with "Related Record ID" (please see below). How do I create an action to update the field I want it to? (Last Account Comment - Text Field)

Apologies for the newb question, I have spent a long time going round in circles on this :)

Thanks Thomas!

JordanUser-added image
Jordan HoldsworthJordan Holdsworth
Hi Thomas,

Please ignore my last comment :) Realised you were able to use the standard "update records" action type :)

WIll test this now! Thanks again!!
Tom HoffmanTom Hoffman
If you use my process from above, you don't need a quick action, you an just have the process flow handle it. 

You should be able to use the Parent ID for the Related Record ID, just so long as you have specified that ParentID starts with 001 in the criteria step. 

Your fields have to be added to the quick action layout I believe for you to be able to define them in this manner. 

Again, you can probably just use the PB to update your records, cut out the quick action altogether. 
Jordan HoldsworthJordan Holdsworth
Hi Thomas,

yes your solution worked! Thank you very much for your help, it is highly appreciated!

The only change I made was to change the field from a text format to a rich text format in order to get ride of the post tags, other than that it works a treat.

Thanks again.

Jordan Holdsworth
Tom HoffmanTom Hoffman
Glad to help! When you get a moment, can you mark this as resolved by selectiing a best answer, it'll help clean up the queue and provide an answer for others in community.   Best of luck!
Jordan HoldsworthJordan Holdsworth
Hi Tom!

i hope you are well! Further to this miraculous fix, could you help me with an add-on to this? We have had an additional requirement to include three of the previous comments as well, so as well as latest comment, which we have (I also added a comment time field with a timestamp formula), we are looking to show the previous comments added to the chatter feed with a max set to 3. Do you think this can be done?

Thanks Tom.

Kind regards

Jordan
Tom HoffmanTom Hoffman
bleh...who comes up with these requirements? haha. 

I would tell my managers/directors/users who are requesting this feature that the chatter feed is readily available to them if they want to see a full history of the comments. 

This is technically possible, you would need 5 fields to do it and a one helluva process builder. 

Field 1: Comment 1
Field 2: Comment 2
Filed 3: Comment 3
Field 4: Long Test Field

Process Flow:

Content Feed created
Comment 2 is null boolean true
+ your other criteria

Field update:
Update Comment 1 with new comment

Comment 2 is null boolean false
Comment 3 is null boolean True
+ your other criteria

Update Comment 3 with new comment

Comment 2 is null boolean false
Comment 3 is null boolean false
+ your other criteria

Copy Comment 2 to Comment 1
Copy Comment 3 to comment 2
Update Comment 3 with new comment

After each one of these, you would want to invoke the next process that aggregates Comment 1, Comment 2, and Comment 3 into one long text field. 


However, just because you can do something, does not mean you should.  At face value without knowing more, the ask does not seem like it will add a lot value to the business process for the effort.  With the chatter feed being located directly on the page, it just seems unnecessary right? Feel free to pretend you never read my answer and say, 'no...not without a lot of custom code.'

 
Jordan HoldsworthJordan Holdsworth
I know right! Why can't people just be happy with what they have :D

Thank you for your answer, I settled for a simple solution somewhere in the middle of the long process above and what was requested from my team.

In the initial process builder, I simply added a criteria evaluation to say is "latest comment" is null - boolean - false? if true it will copy the value from the latest comment to second latest comment and same with the time, copies from comment time to second comment time.

This way it will always run the criteria before running the final criteria and updating the "latest comment" field.

I think I should be able to continue doing this and daisy chaining the process, but I will stop a second comment :)


Thank you very much for your help on this once again, I really appreciate it.

Jordan
Sarah EptingSarah Epting
This didn't work on the opportunity for some reason.
Tom HoffmanTom Hoffman
Didn't work is a little vague - can you provide some more information?
Sarah EptingSarah Epting
Sure...so my real use case is to take the latest feeditem created date and have that fill in a date/time field I created on the opportunity.  I want that field to update everytime there is a new post.  However I followed the logic here and wasn't able to make that successful.  So to test whether or not this would work in the existing use case I created a text area field to duplicate the latest post on the opportunity object.  Then I did the same logic above.

Step 1

User-added image

User-added image

But then just to double check, I did the exact same thing on the account object it worked.

Like I said, what I am really looking for a solution for is to have a date/time field for the latest chatter post on the opportunity.
Tom HoffmanTom Hoffman
That is strange - its all configured correctly.  

Hve you tried it with a Date/Time field on the opportunity & populating with the formula Now()

 
Neftali NavaNeftali Nava
Hello Tom,
Could you help me on this similar case?
I need to update a custom field in a Case named "Last chatter feed timestamp" with the date/time of the last Comment Post in the Case Feed... I tried this process with the Process builder and following your previous answer on this topic, but it doesn't work.
Object: FeedItem
No criteria—just execute the actions!
action:
User-added image
Then when I enter a new comment in the Post section, nothing happeng with my field in the Case.

Any idea how to do it working?
Regards
Neft
 
Tom HoffmanTom Hoffman
Your record to update should just say: [Feed Item).ParentID (Case). It looks like you clicked through the ParentID (Case)> and then selected that case's parent case ID instead of selecting the ParentID (Case) field.
Neftali NavaNeftali Nava
Hello Tom..
I have updated the object and selected the [Feed Item).Parent ID (Case)... but it didn't work.
When I write a new comment in the Post (Feed) section... nothing happen with my case's field
Any idea?
thanks in advance
Kaeli SanerKaeli Saner
Thanks @Tom Hoffman - this helped steer me in the right direction for updating a value on the parent case record when a new feed item is created.
Tom HoffmanTom Hoffman
This thread just keeps going & going :) Glad it helped.
Andrew SteinAndrew Stein

Hi Tom, 

You mentioned that you have another process that adds your initials and date to the end of the comment. How can I add that to this process as well?  Similarly to the above, I made the field rich-text to remove the post tags (not sure if that affects your answer). 

Tom HoffmanTom Hoffman
Andrew, just have to add a few lines to your formula like this:

Left($User.Firstname,1)&Left($User.LastName,1)&' '&TEXT(TODAY())