- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 01:01 PM
I have a question on the best way to create work notes on a Change request based upon a Run Script Action in the Change workflow.
This is the code for the Change Work Flow Run Script Action
if (workflow.scratchpad.sendmail===undefined){
var gr = new GlideRecord("task_service_offering");
gr.addQuery("task", current.sys_id);
gr.addQuery("u_type", "impacted");
gr.query();
while (gr.next()) {
gs.eventQueue("impacted.so.notification", gr);
}
workflow.scratchpad.sendmail="true";
}
As you can see the script above, there is an event created called "impacted.so.notification" that passes a glide record as parm 1. The ask is to create a work note on the current Change for every email that is generated by this Run Script Action. My question is what is the proper way from a platform architecture perspective on how to achieve this. Since it appears that a "Script Action" can be fired from an event, having not worked with them before, I was wondering if I should head down that path?
Thanks - Tom
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 02:06 PM
Hi,
It may be that the current object is only updated once per run script.
With that said, you can create a separate loop like:
if (workflow.scratchpad.sendmail===undefined){
count = 0;
var gr = new GlideRecord("task_service_offering");
gr.addQuery("task", current.sys_id);
gr.addQuery("u_type", "impacted");
gr.query();
while (gr.next()) {
gs.eventQueue("impacted.so.notification", gr);
count = count + 1;
}
for (var i = 0; i < count; i++) {
var gr2 = new GlideRecord('current_table_name');
gr2.get(current.sys_id);
gr2.work_notes = "Hello World!";
gr2.update();
}
workflow.scratchpad.sendmail="true";
}
So this is a round about way to get the current record updated multiple times without using current.update();
Just replace current_table_name with the table name this workflow is running on.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 01:27 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2023 06:07 PM - edited 03-23-2023 06:09 PM
Hi,
Thanks for the video 🙂
I don't know if script actions apply here? This was talking about a Run Script activity in a workflow to trigger an event to fire a notification. You may have been searching for specific keywords to post your various videos?
In any case, thanks anyway!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!