adds the additional comment twice

Community Alums
Not applicable

Hi, I have written a server script in a ServiceNow widget. When this code executes, it adds the additional comment twice. I want it to create the comment only once

 

here is my code

 
if (input.app) {
    // gs.addErrorMessage("my comments "+input.app);
	  // gs.addInfoMessage("my my approval record "+input.Record_sys_id);
	  var approvalSysId = input.Record_sys_id;

  var grApproval = new GlideRecord('sysapproval_approver');
  if (grApproval.get(approvalSysId)) {
		  grApproval.state='rollback';
		  grApproval.update();
    var taskSysId = grApproval.sysapproval;
    if (taskSysId) {
      var table_name=taskSysId.getRefRecord().getTableName();
       var grBR = new GlideRecord('sys_journal_field')
			        grBR.setWorkflow(false);
							grBR.query();
							grBR.initialize();
							grBR.name =table_name ;
							grBR.element = 'comments';
							grBR.element_id =taskSysId;
							grBR.value = input.app;
							grBR.insert();
    }
  }
  } 
5 REPLIES 5

@Community Alums 

your script should update it only once.

any before update business rule is causing this?

Please share some screenshots etc

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader