
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2025 07:26 AM - edited 02-05-2025 07:27 AM
I was wondering if anyone has had a use case for a query business rule to hide an RITM after submission and it causing issues with the workflow attaching.
As an example, I have a query rule on TASK to hide a specific RITM from end users who do not have a specific role, this works fine because both the submitters and fulfillers have the role. My new use case requires that even the submitter cannot see the RITM after submission.
I've built the query rule as such:
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.hasRole('ROLE GOES HERE') && current.getTableName() != 'sc_task') {
current.addEncodedQuery('cat_item!=3e73cbdadb22da50f3dfa8c913961957^ORcat_itemISEMPTY');
}
if (!gs.hasRole('ROLE GOES HERE') && current.getTableName() == 'sc_task') {
current.addEncodedQuery('request_item.cat_item!=3e73cbdadb22da50f3dfa8c913961957^ORrequest_item.cat_itemISEMPTY');
}
})(current, previous);
However, it appears that because the submitter does not have the required role it is causing issues where the workflow does not get created/attached to the RITM.
I know I could probably achieve this with ACLs but we were trying to avoid the "Records have been removed because of security constraints" message, as that caused a lot of confusion for some users last time we implemented something in that manner.
Any thoughts on how to work around wit the query rule?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 02:26 PM
So I was able to solve this myself.
I added an onAfter business rule to SC_REQ_ITEM, it triggers on insert with a filter of "cat_item =" and having it match to the appropriate catalog item,.
I then have an advanced script to re-attach a new workflow
var workflow = new Workflow();
workflow.cancel(current);
var newWorkflow = new Workflow();
current.context = newWorkflow.startFlow(new Workflow().getWorkflowFromName('WORKFLOW_NAME_GOES_HERE'), current, '');
current.update()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 02:26 PM
So I was able to solve this myself.
I added an onAfter business rule to SC_REQ_ITEM, it triggers on insert with a filter of "cat_item =" and having it match to the appropriate catalog item,.
I then have an advanced script to re-attach a new workflow
var workflow = new Workflow();
workflow.cancel(current);
var newWorkflow = new Workflow();
current.context = newWorkflow.startFlow(new Workflow().getWorkflowFromName('WORKFLOW_NAME_GOES_HERE'), current, '');
current.update()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 06:28 PM
@Community Alums Glad to know that your issue is fixed. However, I am still not able to wrap my head around as how cancelling an existing context and creating a new context will avoid the query BR.