Check whether additional comment is not empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 10:25 PM
Hi Experts,
What could the best method to check if additional comment is not empty in a background and business rule.
var gr = new GlideRecord('incident');
gr.get('b64f102567f551101a1136dbd36d434d');
gs.print(gr.number);
gs.print(JSUtil.nil(gr.comments));
//gs.nil()
based upon which i wish to call an api. Please help.
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 11:10 PM
Hi,
Comments is a Journal entry. So, try this
var gr = new GlideRecord('incident');
gr.get('b64f102567f551101a1136dbd36d434d');
gs.print(gr.number);
gs.print(gs.nil(gr.comments.getJournalEntry(1)));
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 12:06 AM
May i please know why the below code will fail in BR.
(JSUtil.nil(gr.comments))

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2022 12:10 AM
Hi,
for Journal fields, data is not stored as plain text. So gr.comment will always return blank value.
The command I shared will check whether Journal has atleast one entry
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 11:10 PM
Hello Aksh,
You will not be able to find if the comments is empty or not using the background script. These can be changed while insert or update operation happening on the incident table. you can check the last comment added on incident using
gs.print(gs.nil(gr.comments.getJournalEntry(1)));
If you want to check the comments field is empty or not then I think you can create a before update BR with below script:
if(current.comments.changes()) {
// write your code here
}
Please mark my respsone as helpful/correct, if it answer your question.
Thanks