
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 07:22 AM
Hello,
I have an order guide/catalog item that uses a variable set and the variables are cascaded. If someone changes a variable on an associated task I want to capture the change in the activity stream work note. How can I accomplish this?
Thanks,
Joe
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 01:04 PM
Can you test this once
var key;
for(key in current.variables){
if(current.variables[key] != previous.variables[key]){
current.work_notes = "Variable changed "+key + "Value Changed to"+current.variables[key];
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 07:26 AM
Write a Business rule Which will check the values of variables
if(current.variables.variable1 != previous.variables.variable1){
current.work_notes ='field changed';
}
I haven't tested it but I think it will work
Regards
Pranav

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 08:11 AM
Thank you for the reply Pranav!
I created a new Business Rule on the sc_task table and put this script in the advanced tab. There is an error on the script single quotes before field changed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 08:14 AM
Hi,
Try this
Ensure this BR runs only for your catalog item so give your catalog item name here
BR: Before update on sc_task
Condition: current.variables.changes() && current.request_item.cat_item.name == 'Catalog Item Name here'
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.work_notes = 'Variable Changed';
})(current, previous);
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2020 09:16 AM
Ensure you use valid business rule condition so that it works only for your catalog item.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader