- 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 05:32 PM
Can you check the dictionary of project_manager, if it is a reference field of user table and what is the table name of this field?
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2024 05:44 PM - edited ‎07-08-2024 05:46 PM
It is a reference field to the sys_user table. The field, unlike assigned_to, assigned_group and opened_by, however, is on the pm_project table. The others I mentioned (of which the query works) are from the task table.
I suspect this is part of the problem, but I can't tell why if that's the case.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2024 07:16 AM
Ohh....In that case, I would suggest building the query in the List view first and then copy that query. If the table is in pm_project, parent.project_manager doesnt work.
I think in your case it will be parent.ref_pm_project.project_manager
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-08-2024 05:55 PM
Hi @Fabricio4,
Try applying all the above filters manually on the list of the table. Hope you can figure out the issue then.
If not, right click and copy the query. Use addEncodedQuery in the business rule and make the modifications as required to make it work dynamically.
Mark the response correct and helpful if the answer assisted your question.