Upadte worknotes through workflow script with 4 record numbers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 03:04 AM
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() ;
}
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 03:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2022 03:18 AM
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
Regards,
Abhijit
ServiceNow MVP