Skip to content

Commit 17207fe

Browse files
authored
Add comments using set journal entry (#1384)
* Create style.css * Create readme.md * Delete Styles/Add Background Color directory * Create addComment.js Function to add comments to a record through setJournalEntry() * Create readme.md * Update addComment.js Fixed the spelling error in setJournalEntry
1 parent 56a5185 commit 17207fe

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
function addComments(tableName,recSysId, userName, fieldName){
2+
var rec = new GlideRecord(tableName);
3+
if(rec.get(recSysId)){
4+
rec[fieldName].setJournalEntry('This is my comment',userName);
5+
rec.update();
6+
}
7+
}
8+
9+
addComments(tableName,recSysId,userName,fieldName);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
There have been scenarios where you are working on an integration and one of the usecase is to add comments on a record. In this scenario once you add comments directly
2+
to the record by assigning the value in the comments or work_notes field, it captures it as a integration user in the activity formatter. But with setJournalEntry()
3+
method you can pass the user_name and it will add the comment on behalf of the user whose user_name is passed. In this way it easy to track who is actually modifying
4+
the record or adding the comments. Hope this will be a helpful snippet.
5+
6+
In this function the paramters are defined as:
7+
tableName: Name of the table on which you are adding the comments.
8+
recSysId: sys_id of the record for which the comment is getting added.
9+
userName: user_name of the user who is adding the comments
10+
fieldName: It can be either comments or work_notes or any custom journal entry field.

0 commit comments

Comments
 (0)