Display only the records created by the currently logged in user and also the records where caller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 11:26 PM
Display only the records created by the currently logged-in user and also the records where the caller person should be currently logged in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-19-2023 11:49 PM
Try with before query Business Rule on your required table and in the script field of business rule try something like below.
(function executeRule(current, previous /*null when async*/ ) {
current.addEncodedQuery('sys_created_by='+ gs.getUser().getName()+'^caller_id='+ gs.getUserID());
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2023 12:27 AM
By using before query rule, you can achieve this,
Condition exclude admin role
Please check and Mark Helpful and Correct if it really helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2023 12:33 AM
Create Before - Query Business rule with:
current.addQuery('sys_created_by', gs.getUserName()).addOrCondition('caller_id', gs.getUserID());
Hop this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-20-2023 12:42 AM
Hi @Abhishek Kathe ,
I trust you are doing great.
Please find the code as given below
// Script to fetch records created by or where the caller is the currently logged-in user
(function() {
var currentUser = gs.getUserID(); // Get the sys_id of the current user
var gr = new GlideRecord('incident'); // Replace 'incident' with your target table
// Add OR condition: Created by current user OR Caller is current user
gr.addQuery('sys_created_by', currentUser);
gr.addOrCondition('caller_id', currentUser);
gr.query(); // Execute the query
while (gr.next()) {
// Process your records here
// Example: gs.info(gr.number); // Log the incident number
}
})();
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi