- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 08:24 AM
How do I create a Flow in Flow Designer to run after a Comment is added to an Incident? It is easy enough to specify the trigger condition (Additional comments changes), but how do I access the comment itself, which is a journal field?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 02:08 PM - edited 05-14-2025 02:09 PM
Hello!
Based on some very brief research, it doesn't appear that there is an OOTB way to pull the last entry for journal fields in Flow Designer (here for some reference).
My suggestion and go to method for these types of situations is to create a Flow Variable, and script its value:
- Navigate to your flow.
- Click the More Action menu (three dots), and select Flow Variables.
- Create a new variable, something like Last Comment [last_comment], and select String for its type.
- Back in your flow, add a Flow Logic > Set flow variables action.
- Add the Last Comment variable, and add the following script:
var inc = fd_data.trigger.current;
return inc.comments.getJournalEntry(1);
And that's it! You can save your flow and access the value using the Flow Variable. See attached too for some visuals. If this is something you find yourself doing often, you might want to consider creating a dedicated Flow Action.
If you are unfamiliar with Flow Variables or JavaScript, I recommend the following:
Hope that helps! Let me know if you have any questions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 08:32 AM
yes condition is fine
you can access the value of comments using the "Changed Field" data pill
refer below link
Using the data within the "Changed Fields" Pill
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 01:33 PM
That was helpful; but not really a solution. "Changed Fields" does not return the comment that was just added. It returns all the comments added since the Incident was opened. The comments are concatenated together as a giant string and embedded in an array that includes all the changed fields. Is there no way of accessing the new comment other than writing JavaScript to parse that string? If you need to write JavaScript for every simple thing, when what is the point of using Flow Designer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 02:21 PM
You shouldn't have to parse the entire string as there is already a JavaScript method for this (getJournalEntry), but I understand your frustration around Flow Designer and JavaScript. I come from a development background and sometimes I feel like Flow Designer just gets in the way, especially if ServiceNow hasn't addressed specifically what you're trying to do.
I am seeing a Current Value variable under the Changed Fields object in Flow Designer. Is this available for you? What is its value (see attached)?
You could also do a lookup on the Journal Entires [sys_journal_field] table if you want to avoid scripting, but that seems a bit messy to me (Have to take into consideration the security context of the flow), and just using the script would be less actions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 02:08 PM - edited 05-14-2025 02:09 PM
Hello!
Based on some very brief research, it doesn't appear that there is an OOTB way to pull the last entry for journal fields in Flow Designer (here for some reference).
My suggestion and go to method for these types of situations is to create a Flow Variable, and script its value:
- Navigate to your flow.
- Click the More Action menu (three dots), and select Flow Variables.
- Create a new variable, something like Last Comment [last_comment], and select String for its type.
- Back in your flow, add a Flow Logic > Set flow variables action.
- Add the Last Comment variable, and add the following script:
var inc = fd_data.trigger.current;
return inc.comments.getJournalEntry(1);
And that's it! You can save your flow and access the value using the Flow Variable. See attached too for some visuals. If this is something you find yourself doing often, you might want to consider creating a dedicated Flow Action.
If you are unfamiliar with Flow Variables or JavaScript, I recommend the following:
Hope that helps! Let me know if you have any questions.