add a title in worknote & comments
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 01:04 AM
Hello everyone,
From Washington DC. version I have regular incidents that come up concerning comments that are written several times, or even written in the name of other people. You should know on the instance on which I work there is a BR which exists and which adds a title to each comment according to business logic, of which here is an extract:
if (answer == 'true') {
current.work_notes = current.assignment_group.getDisplayValue() + "\n ****************************";
}
// If the current logged in user has an Initial Group
else if (answer != 'true' && !groupInit.nil()) {
// Fill the Incident Initial Group field
current.work_notes = groupInit.getDisplayValue() + "\n ****************************";
}
After analysis, I realized that the script in question had modified the value of the comment field but on the sys_journal_field table it created two records: 1 with the text of the comment, the other with the title. (see screenshot).
I therefore decided to change this operation, and to do the work on the client side by adding a Client script which, according to the same business logic, adds the title to the comment upon submission. It works very well except that...
if the user clicks on the post button, then the comment is added without submitting the form, therefore without launching my client script. (I tried to do another client script on the edit one, or we change but nothing to do) and as soon as I make a rule on the server side, then this stores two records on the sys_journal_field table, and therefore this amounts to what I don't want to, so as not to end up with the same incident...
Does anyone have any leads or ideas, thank you very much in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 02:35 AM
Mentioning the Washington version - was this in place and not happening in a prior version, or are you just mentioning the version you are on? On the Business Rule you've shown a snippet from, is this running before Insert and Update when Work notes changes? On which table? What does the activity stream on whichever table record look like for the test case that you've shown the journal table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 12:23 PM
hi Brad,
the first incidents arrived with Washington version. The business rule is before and in the condition: additional comments "change" on the table "incident".
The activities is normal, like the screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2024 12:42 PM
Work notes and additional comments are two separate journal fields, so if the BR triggers on comments, it wouldn't run when the work notes change. The script snippet you are showing only sets the value of the work_notes field to something like AMOA_SPICE ************ it's not appending it to the actual work note (test, tst,...) so you must have other Business Rules and/or the entire script would show what is actually happening.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-16-2024 12:06 AM - edited 09-16-2024 12:26 AM
Hi Brad, i modified the rules, i deactivate all existing and added this:
A client script on incident's table on submit that launch this script:
function onSubmit() {
//Type appropriate comment here, and begin script below
var prefix = "";
var comments = g_form.getValue('comments');
if (comments != "" || comments.includes('support' == false)) {
prefix = "[code]<h4>Support Enedis</h4>[/code]";
g_form.setValue('comments', prefix + comments);
}
}
and a business rule on the incident's table, in insert and update , onBefore when the additionals comments change, tha launch thist script:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var comments = current.getValue('comments');
if (GlideTransaction.get().getRequest()) {
var referer = GlideTransaction.get().getRequest().getHeader("referer");
var isServicePortalURL = new GlideSPScriptable().isServicePortalURL(referer);
}
if (comments != "" && comments.includes('Support ENEDIS') == false && isServicePortalURL == false) {
prefix = "[code]<h4>Support ENEDIS</h4>[/code]";
current.comments = prefix;
}
})(current, previous);
The first one (CS) work correctly when i save the form, in the sys_journal_field the title and the message are on the same record.
But the second (BR), made for the post button, create 2 records on the sys_journal_field table , one for the title, and one for the message.
In my form, there is no difference, all of them are correctly displayed.