How to avoid creation of duplicate comments?

devendranarun
Tera Guru

Hi All,

I am facing Duplicate issues in Additional Comments field.

When i update a comment from Incident to Case, it displays 2 comments in Incident form and displays 1 comment in Case form.

Also, when i update a comment from Case to Incident, it displays 2 comments in Case form and displays 1 comment in Incident form. 

Mapping Additional Comments from Incident to Case. 

Table: Incident

When to run: after update

Filter Condition: Additional Comments Changes

 

var latest = current.comments.getJournalEntry(1);
var notes = latest.substring(latest.indexOf(")")+1).split("/n/n");
var gr = new GlideRecord('sn_customerservice_case');
gr.addQuery('sys_id',current.u_case);
gr.query();
if(gr.next())
{
gr.comments = "Comments updated from "+current.number+"\n"+notes;
gr.update();
}

 

Mapping Additional Comments from Case to Incident 

Table: Case

When to run: after update

Filter condition: Additional Comments changes

 

var latest = current.comments.getJournalEntry(1);
var notes = latest.substring(latest.indexOf(")")+1).split("/n/n");
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.parent);
gr.query();
if(gr.next())
{
gr.comments = "Comments updated from "+current.number+"\n"+notes;
gr.update();
}

8 REPLIES 8

Tony Chatfield1
Kilo Patron

Hi, perhaps the first step is to check the 'duplication' and clarify if it is a result of the same script running multiple times,
or a result of the record that is being updating then triggering an additional update to the related (source) record.
A condition to exclude updates that are not a result of UI action might be a solution
https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_ScopedGlideSessionIsInteractive
But before making any decision it is important that you work out why this is occurring.

Pavel87
Kilo Contributor

Hi,

 

Did you had a chance to solve it? I am facing the same issue, when the approver is saving comments in SP, system is populating the comments twice every time. 

I checked that when I am performing such action from the backend perspective (and saving approval comments), system is not creating duplicates, so the issue is somewhere in the "Approval info" widget most probably.

I've used solution from below links, but still the issue persist.

https://community.servicenow.com/community?id=community_question&sys_id=00d3004adba5334423f4a345ca96...

https://community.servicenow.com/community?id=community_question&sys_id=bfc2a8d4dbb0f34413b5fb243996...

 

Thanks

Hi Pavel, 

I see that you commented on a number of questions similar to this. 

A solution seems to be to comment out the line below in the Client controller. I believe the update is already being done in the Server Script. 

c.data.op = state;
c.data.state = state;
//c.server.update();

Please be sure to close down the browser completely as mentioned in https://community.servicenow.com/community?id=community_question&sys_id=bfc2a8d4dbb0f34413b5fb243996... 
Lesson the second: Always always do a hard reload when testing a change.

Please let me know if this works for you too. I haven't noticed any side effects. 

Him Phonsie,

 

Thank you for your response, however in my situation it was not the case. To solve it I had to use the solution from below link:

Approval widgets saving comments more then once

I had to modify the client controller and use respone function, by some reasons it solved the issue.

 

Thanks