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 autopopulate the worknotes of incident form to its incident task worknotes?

Divi
Mega Guru

I just wanted to populate the worknotes of an incident form to its related incident task form worknotes?

Can i expect a solution for this?

Thank you in advance!

1 ACCEPTED SOLUTION

Divi
Mega Guru

Hi all,

Thank you for your response but i somehow got the solution for this problem.

 

After business rule :

condition: current.isValidRecord() &&current.work_notes.changes()

 

script:

(function executeRule(current, previous /*null when async*/) {

updateRelatedIncidents();

 

function updateRelatedIncidents() {

var rec = new GlideRecord("problem_task");// Add the table name which needs to copy the work notes

rec.addActiveQueryry();

rec.addQuery("problem_id", current.sys_id);

rec.query();

while (rec.next()) {

 

rec .work_notes =current.work_notes.getJournalEntry(1);

 

rec .update();

}

}

 

 

})(current, previous);

 

View solution in original post

4 REPLIES 4

asifnoor
Kilo Patron

Hi Divya,

Write a BR script (after update) on the incident table and then add the below script in that Br. 

if (current.work_notes != previous.work_notes) {
  var gr = new GlideRecord("incident_task");
  gr.addQuery("incident",current.sys_id);
  gr.query();
  if (gr.next()) {
    gr.work_notes = current.work_notes;
    gr.update();
  }
}

Mark the comment as a correct answer and also helpful once worked.

Var notes = current.work_notes.getJournalEntry(1);

var gr = new GlideRecord("incident_task");

gr.addQuery("incident",current.sys_id);

gr.query();

while (gr.next()) {

gr.work_notes = notes;

gr.update();

Write business rule on incident which is of after update with condition as work notes changes

Divi
Mega Guru

Hi all,

Thank you for your response but i somehow got the solution for this problem.

 

After business rule :

condition: current.isValidRecord() &&current.work_notes.changes()

 

script:

(function executeRule(current, previous /*null when async*/) {

updateRelatedIncidents();

 

function updateRelatedIncidents() {

var rec = new GlideRecord("problem_task");// Add the table name which needs to copy the work notes

rec.addActiveQueryry();

rec.addQuery("problem_id", current.sys_id);

rec.query();

while (rec.next()) {

 

rec .work_notes =current.work_notes.getJournalEntry(1);

 

rec .update();

}

}

 

 

})(current, previous);