Why this Business Rule Script not working fro me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:05 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:34 AM
hii @Danish Bhairag2 @Ankur Bawiskar
means last year incident shown for non admin user , when it's opening incident form
Condition :- !(gs.hasRole('admin'))
Script:-

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:50 AM
Try this, I hope you are writing query business rule.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.addEncodedQuery('sys_created_onONLast year@javascript:gs.beginningOfLastYear()@javascript:gs.endOfLastYear()');
})(current, previous);
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:55 AM
Hi @1dusjhyahnt ,
What is the business requirement exactly. Why do u want to show tickets created in Last Year Only for non admin users? Because writing a BR will restrict the visibility globally & not only on LIST view.
But still if u want to proceed see below steps:
Please make sure u have a query Business rule for this & under condition field in advanced u can provide
!(gs.hasRole('admin'))
& in the script section u can paste below code
current.addEncodedQuery('sys_created_onONLast year@javascript:gs.beginningOfLastYear()@javascript:gs.endOfLastYear()');
Thanks,
Danish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2023 12:46 AM
Try this, I hope you are writing query business rule.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
current.addEncodedQuery('sys_created_onONLast year@javascript:gs.beginningOfLastYear()@javascript:gs.endOfLastYear()');
})(current, previous);
Regards,
Musab