Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Hi Pavel,

Thanks for your reply. The solution you mention above works well for the widget where you have the list of approvals. I was having that issue now when I was trying to add the rejection comments to this page. But the solution I proposed works when you are approving or rejecting on one specific approval.

Kind regards,

Phonsie

Hello Pavel87,

Is their any update on this issue ? 

Mandeep Karan
Kilo Sage

Use gr.setWorkflow(false) in your script.

Upender Kumar
Mega Sage

try to use below condition in both the BRs

session.isIntractive()