
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 05:44 PM
Ok, so I'm creating a flow action that gets the last comment - that part works fine, however it shows like this:
Ultimately I want to only use the text after the (Comments) part like:
This line removed:
The script I have currently is not showing anything after it tries to remove the text.
var str = inputs.full_comment;
str = str.substring(str.indexOf(")") + 1)
outputs.comment = str;
With my input being called "full_comment
My output being called "comment"
I can see in the results that it is getting the full comment, but then not showing any text as a output "comment"
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 04:40 PM
@Moedeb - Thanks.
Honestly, I think it's related to your first "look up record" step and how you're receiving the "Comments" as an input (which SN doesn't seem to be able to handle). Instead of receiving the comments as an input, try and receive the entire record, and then grab the comments journal entry in your script:
(function execute(inputs, outputs) {
var fullComment = inputs.approval_record.comments.getJournalEntry(1);
var trimmedComment = fullComment.substring(fullComment.indexOf(")") + 1);
outputs.comment = trimmedComment;
})(inputs, outputs);
Example:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 08:48 PM
Thanks - If you do some `gs.info()`s in your script and check the system logs, do you see the expected results there?
eg:
gs.info("Test: " + str);
before and after you call `.substring()`, what do you see?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 09:49 PM
I added the toString() back just to make sure again and the text that gets added from the comment is:
com.glide.glideobject.Journal@3677c89a
As for the logs:
When I removed the toStiring however:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2024 10:48 PM
are you sure the script step in your action is getting the correct input.
the logic I shared will work fine provided you pass the correct and full comment to it
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 02:53 PM
@Ankur Bawiskar the input seems to be getting the full comment. When I look at the execution of the action it is showing that it has gotten the full comment
It just isn't getting the edited comment, so not sure if the issue is with the script or the way I am trying to pass the result to the output?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2024 04:40 PM
@Moedeb - Thanks.
Honestly, I think it's related to your first "look up record" step and how you're receiving the "Comments" as an input (which SN doesn't seem to be able to handle). Instead of receiving the comments as an input, try and receive the entire record, and then grab the comments journal entry in your script:
(function execute(inputs, outputs) {
var fullComment = inputs.approval_record.comments.getJournalEntry(1);
var trimmedComment = fullComment.substring(fullComment.indexOf(")") + 1);
outputs.comment = trimmedComment;
})(inputs, outputs);
Example: