- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 03:13 AM
HI , I have a requirement to update activity log in the notes section when the close note are filled and saved :
I have used this script , it is working but giving the following error:
Code:L
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// Check if the Close Notes field is not empty
if (newValue) {
// Get the current user's name (or any other identifier you want to use)
var currentUser = g_user.getUserName();
// Get the current date and time
var currentDate = new Date();
var formattedDate = currentDate.toISOString();
// Construct the comment to be added to the activity log
var comment = currentUser + ' updated Close Notes on ' + formattedDate + ': ' + newValue;
// Add the comment to the 'Notes' tab in the activity log
// g_form.addInfoMessage(comment);
var activityRecord = new GlideRecord('sys_journal_field');
activityRecord.initialize();
activityRecord.setNewGuidValue();
activityRecord.setValue('element', 'comments');
activityRecord.setValue('type', 'comment');
activityRecord.setValue('value', comment);
activityRecord.setValue('group', g_form.getUniqueValue()); // Link to the change record
activityRecord.insert();
}
//Type appropriate comment here, and begin script below
}
ErrorL
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 03:27 AM
Hi,
Why you are using script to update activity logs?
You can configure the fields that should appear in activity log by making small change.
Follow below steps:
1. Open any change record:
2. Scroll to Activities in Notes section.
3. Click on the Funnel icon to configure filter
4. Add the Close Notes field. and save the selection.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-01-2023 03:27 AM
Hi,
Why you are using script to update activity logs?
You can configure the fields that should appear in activity log by making small change.
Follow below steps:
1. Open any change record:
2. Scroll to Activities in Notes section.
3. Click on the Funnel icon to configure filter
4. Add the Close Notes field. and save the selection.
Thanks
Anil Lande