- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2023 11:29 PM
Hi,
I want to hide incident task slas with SLA definition "N Incident Resolution SLA", I tried to restrict them using before query BR. The if blocks are triggering fine with the info messages, but the query is not applying. Can anyone please help me.
Here is the details of BR
Table : task_sla
Note: "u_type_of_user" is a field in sys_user table
Thanks 🙂
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-09-2023 04:47 AM - edited 07-09-2023 04:48 AM
@Aruna Sree Yela I am assuming that you do not want to display some SLA records for a certain type of user.
1. I created a field in my "sys_user" table called 'u_type_of_user' and provided the choices 'external' & 'internal'. If the logged in user is external, I don't want few SLA records to be displayed. (please correct me if my understanding is wrong).
2. Added a new before query Business Rule on the 'task_sla' table with the below script.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var user_rec=new GlideRecord('sys_user');
user_rec.get(gs.getUserID());
if(user_rec.u_type_of_user=='external'){
current.addEncodedQuery('sla!=35420982d732220035ae23c7ce610393');
}
})(current, previous);
This script will not allow me to see the Task SLA records that belongs to a specific SLA definition if I am an external, else it will be as usual.
If your expectation is to modify the query that is executed against the TASK SLA table, then you should use the variable current. In your above script 17-31 needs to be rewritten to use current.addQuery instead of gr.query.
Please mark the appropriate response as correct answer and helpful.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2023 10:27 AM
The BR on the sla_task table should do the work. please check.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var user_rec = new GlideRecord('sys_user');
user_rec.get(gs.getUserID());
if (user_rec.u_type_of_user == 'external') {
var Ngroups = new GlideRecord('sys_user_grmember');
Ngroups.addEncodedQuery('group.nameSTARTSWITHinternal^group.active=true^user=' + gs.getUserID());
Ngroups.query();
if (!Ngroups.next()) {
current.addEncodedQuery('sla!=35420982d732220035ae23c7ce610393');
}
}
})(current, previous);
Please mark the appropriate response as correct answer and helpful.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2023 04:58 AM
@Aruna Sree Yela did you get a chance to check this Business Rule, is it working as expected.
Please mark the appropriate response as correct answer and helpful.
Thanks!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2023 05:22 AM
Kindly accept the solution if this answered your query.
Thanks!!