- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-25-2024 05:21 AM - edited ā10-25-2024 05:24 AM
Hi Team,
I have a business rule - Before insert and update to copy all incident updates to other custom table record.
All fields are copying except work notes and comments.
My requirement is
1. Copy all the work notes and comments except time and user stamp to multi line text field in other custom table.
2. Business rule is triggered on every update so i would like to add if condition for latest work notes and comments.
Thanks,
Anil!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-25-2024 05:53 AM
Hi all thanks for the reply
I got the solution:
var comment;
var workNotes;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-25-2024 05:29 AM
hi @AnilM99
1) Copy all the work notes and comments except time and user stamp:
In the script section of the business rule, add the logic to extract the work notes and comments, excluding timestamps and user information. Hereās an example script:
var customRecord = new GlideRecord('your_custom_table');
customRecord.initialize();
// Copy work notes (excluding timestamps and user information)
var workNotes = current.work_notes.getJournalEntry(1); // Get the latest work note
if (workNotes) {
customRecord.work_notes_field = workNotes.replace(/^[^:]*:\s*/, ''); // Remove user info
}
// Copy comments (excluding timestamps and user information)
var comments = current.comments.getJournalEntry(1); // Get the latest comment
if (comments) {
customRecord.comments_field = comments.replace(/^[^:]*:\s*/, ''); // Remove user info
}
// Insert the custom record
customRecord.insert();
2) Add condition for latest update:
In the Conditions section, you can use a script to check if there are new updates. To capture only the latest work notes and comments, you can do something like this:
// Check if the current record has changes
if (current.changes() && (current.work_notes.changes() || current.comments.changes())) {
// Logic to handle the copying of notes
}
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-25-2024 05:30 AM - edited ā10-25-2024 05:31 AM
hi Anil,
Can you share the BR, what does it do exactly and what type it is?
Is it either triggered on [sys_journal_field] table or using that in the script field in case of triggering on another table?
Also, regarding the point 2. when a comment or a work note is added and saved it will still be triggered I guess, there is no latest comment, the added comment will be always the latest one... or what am I missing?
/* If my response wasnāt a total disaster āļø ā drop a Kudos or Accept as Solution ā āļø Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-25-2024 05:53 AM
Hi all thanks for the reply
I got the solution:
var comment;
var workNotes;