Auto add work note to RITM using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 05:21 AM
Hello,
I have put together a very basic workflow. I am trying to add an activity to automatically set a work note in the RITM once approval has been gained and the catalog task has been created.
I have tried many different options. The most recent is this:
Using a Run Script activity:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 05:39 AM
Your query is on the field "Item" which is not a standard field I believe (I might be mistaken). Did you create a custom one for that?
The actualy reference to the Catalog Item definition is in the "cat_item" field on the "sc_req_item" table. And since it's a reference you would have to query it via the sys id.
The actual update on the work notes seems correct to me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 05:42 AM
So basically something like this:
var itemId = gs.getProperty('property.name.catitem'); //Store your catalog items sys id in a property, name it accordingly and get it via this function
var ritmGr = new GlideRecord("sc_req_item");
gr.addQuery("cat_item", itemId);
gr.query();
while(ritmGr .next()) {
ritmGr .work_notes = "Test WORK NOTE";
ritmGr .update();
}
Also the reminder to avoid naming your GlideRecord objects simply "gr" since that might cause you issues at some point 😉
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 06:14 AM
Thanks Siyabend. Very helpful.
Is there a better way of doing this i.e. not referencing the cat item itself?
Can I just have the script always add a work note into a RITM that uses this workflow? For example have an activity that will add a work note to the RITM once the task is created... it doesn't need to match any conditions? See screenshot of the current workflow. You can see the Run Script activity I am attempting to do this in after the Catalog Task activity.
Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2023 06:34 AM
Hi Nathan
Is the workflow on the request item table?
If so in your query
var ritmGr = new GlideRecord("sc_req_item");
ritmGr.addQuery("sys_id", current.sys_id); // use ritmGr. not gr.
ritmGr.query(); // use ritmGr. not gr.
you can use the current.sys_id to return the record that you are processing