- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 02:03 AM
Hello all,
I want to create before update BR on incident when a new comment is added checks if user belongs to the Assignment group, if yes then set the field value. I come up with the below script but its not working. Any help? Thank you
Condition: current.comments.changes()
(function executeRule(current, previous /*null when async*/ ) {
var recGR = new GlideRecord('sys_journal_field');
recGR.addQuery('element_id', current.sys_id);
recGR.query();
if (recGR.next()) {
if (gs.getUser().isMemberOf('assignment_group')) {
current.setValue('u_last_comment_by', 'resolver');
} else {
current.setValue('u_last_comment_by', 'end_user');
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-22-2022 02:12 AM
Hi,
update as this
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser().isMemberOf(current.assignment_group.toString())) {
current.setValue('u_last_comment_by', 'resolver');
} else {
current.setValue('u_last_comment_by', 'end_user');
}
})(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
09-22-2022 02:12 AM
Hi,
update as this
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser().isMemberOf(current.assignment_group.toString())) {
current.setValue('u_last_comment_by', 'resolver');
} else {
current.setValue('u_last_comment_by', 'end_user');
}
})(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
09-22-2022 02:46 AM
Any special case you are querying the sys_journal_field table? if yes please explain or you can modify your code as below,
(function executeRule(current, previous /*null when async*/ ) {
if (gs.getUser().isMemberOf(current.assignment_group.toString())) {
current.setValue('u_last_comment_by', 'resolver');
} else {
current.setValue('u_last_comment_by', 'end_user');
}
})(current, previous);