- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 10:00 AM
Hi All,
I need to capture the field changes in worknotes sctask form. I have two fields
1.Estimation hours
2.Week and date
These two fields applicable only for this task .when the user updates any changes on these fields previous values should capture in worknotes only for this sctask only...how I can achieve this..any help please suggest me.
Thanks all...
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 10:16 AM
Hi,
Since you need only for 1 tasks out of many for the RITM
You need some unique field value such as short description to identify that particular task
BR: Before Update
Condition: Field 1 or Field 2 changes && current.short_description == 'Task 1'
Sample Script below
var str = '';
if(current.<field1> != '')
str = str + previous.<field1> + ' ';
if(current.<field2> != '')
str = str + previous.<field2>;
current.work_notes = str;
It would look like if field 1 is having hello and field 2 is having abc
hello abc
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
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
06-17-2020 10:07 AM
You can configure business rule and capture previous values
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 10:08 AM
Hi,
Use after business rule on sc_task table
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var set = new GlideappVariablePoolQuestionSet();
set.setRequestID(current.getValue('request_item'));
var workNote = "";
set.load();
var vs = set.getFlatQuestions();
gs.log ('Size: ' + vs.size());
for (var i=0; i < vs.size(); i++) {
if(vs.get(i).getDisplayValue() != '') { // Only get variables that were filled out
workNote = workNote + vs.get(i).getLabel() + ": " + vs.get(i).getDisplayValue() + "\n";
}
}
current.work_notes = workNote;
current.update();
})(current, previous);
Please mark it correct and helpful.
Thanks,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 10:10 AM
Hi,
I want to add something in previous post,
Write a before BR on update checked
Condition.
Estimation hours changes
Code:
(function executeRule(current, previous /*null when async*/) {
current.work_notes = previous.(field_name of Estimation hours).getDisplayValue();
})(current, previous);
Please mark correct and helpful.
Thanks
Tanushree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2020 10:16 AM
Hi,
Since you need only for 1 tasks out of many for the RITM
You need some unique field value such as short description to identify that particular task
BR: Before Update
Condition: Field 1 or Field 2 changes && current.short_description == 'Task 1'
Sample Script below
var str = '';
if(current.<field1> != '')
str = str + previous.<field1> + ' ';
if(current.<field2> != '')
str = str + previous.<field2>;
current.work_notes = str;
It would look like if field 1 is having hello and field 2 is having abc
hello abc
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader