- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2024 04:41 PM - edited ‎07-08-2024 04:45 PM
Hi!
So, I have a request to block some users from seeing Projects and Project tasks that aren't related to them.
I've followed the article below to achieve this with before query business rules:
https://servicenowguru.com/business-rules-scripting/controlling-record-access-before-query-business-...
As well as the OOB business rule "incident query".
It worked great for most of my requirements. There is, however, one nagging query that it just won't work with, and that is the query for parent.project_manager on the pm_project_task table. Here's the code:
})(current, previous);
All of the queries work flawlessly. Parent.assigned_to, parent.assigment_group, etc. The only one that will not work is parent.project_manager. If that's the only query I use, it returns all of the records regardless of the condition. If I use only one of the other queries in isolation, they will all work.
That's also when I've discovered that I cannot add the parent.project_manager column in the pm_project_task list layout (it won't appear even when I dot walk 'parent'), for some reason, so I'm sure I'm missing something here.
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 07:12 AM
Found out the problem.
Turns out I can't reference 'parent.project_manager' because parent is a generic reference, it could be a number of tables being referenced. Instead, I had to use 'parent.ref_pm_project.project_manager' because the 'project_manager' field is inside the pm_project table, so only referencing parent means I couldn't access it.
Thanks everyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2024 09:46 PM
Can you try using parent.project_manager.sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 07:12 AM
Found out the problem.
Turns out I can't reference 'parent.project_manager' because parent is a generic reference, it could be a number of tables being referenced. Instead, I had to use 'parent.ref_pm_project.project_manager' because the 'project_manager' field is inside the pm_project table, so only referencing parent means I couldn't access it.
Thanks everyone.