Upadte worknotes through workflow script with 4 record numbers

Laxmi18
Tera Expert

Hi,

Kindly help me in updating task  work notes through workflow .

Scenario :  4 SADB record is being created through workflow. and  we are fetching those records and need to update in task worknotes. Below is the script

var gr = new GlideRecord("u_security_admin_database");
gr.addQuery('sys_id','IN',workflow.scratchpad.rec);// created values are being pushed to workflow.scratchpad.rec
gr.query();
while(gr.next()) {

current.work_notes = "SADB record creation successful :"+workflow.scratchpad.rec.getDisplayValue() ;
}

2 REPLIES 2

Anurag Tripathi
Mega Patron
Mega Patron

What does the current script do? 

 Your issue would be in this like

workflow.scratchpad.rec.getDisplayValue() ;

Use this instead

var gr = new GlideRecord("u_security_admin_database");
gr.addQuery('sys_id','IN',workflow.scratchpad.rec);// created values are being pushed to workflow.scratchpad.rec
gr.query();
while(gr.next()) {

current.work_notes = "SADB record creation successful :"+gr..getDisplayValue() ;
}

 

-Anurag

-Anurag

Abhijit4
Mega Sage

Hi,

Try below,

var displayValues="";
var gr = new GlideRecord("u_security_admin_database");
gr.addQuery('sys_id','IN',workflow.scratchpad.rec);// created values are being pushed to workflow.scratchpad.rec
gr.query();
while(gr.next()) {
if(displayValues=="")
displayValues=gr.getDisplayValue()
else
displayValues=displayValues+", "+gr.getDisplayValue();

}
current.work_notes = "SADB record creation successful :"+displayValues;

If you want 4 different work notes for 4 records then you can update work notes in while loop.

Let me know if you have any further queries.

Please mark this as Correct or Helpful if it helps.

Thanks and Regards,
Abhijit

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP