Override "user query" Business Rule

Susan Britt
Mega Sage
Mega Sage

We have a custom field, Subcontractor (u_subcontractor), on the sys_user table, which is selected if the user is a subcontractor vs employee.   Once the subcontractor's contract is up and finished with their active project, we unselect the "active" flag for that user.   We have a specific Service Request Catalog for hiring approved (previously used) subcontractors.   The field in the catalog is a reference field back to the sys_user table, with the reference qualifier of "Subcontractor is true".   The problem I'm encountering is when managers or PMs go to the catalog to select an approved subcontractor, they only see the active subcontractors (need to see them all) - due to the "user query" Business Rule.   There isn't any specific role for the possible users that could be entering the request for me to add to the business rule.   I haven't been able to find a way within that business rule to make sure we aren't in the catalog or specific variable before applying the addActiveQuery.   Updating the variable's reference qualifier to include "active = false" does not help.   Has anyone been able to handle this type of situation before?

1 ACCEPTED SOLUTION

mamann
Mega Guru

The reference qualifier won't help because the user query Business Rule is still invoked when searching or clicking the magnifying glass.



If allowing the Users to be searched from all reference fields pointing to sys_user isn't a problem, you should be able to modify the business rule from current.addActiveQuery() to current.addActiveQuery().addOrCondition("u_subcontractor", true);


(Assuming u_subcontractor is the name of the field)



Alternatively you can copy the business rule, mark the original as inactive and change the code so you don't own the OOB rule.


View solution in original post

3 REPLIES 3

mamann
Mega Guru

The reference qualifier won't help because the user query Business Rule is still invoked when searching or clicking the magnifying glass.



If allowing the Users to be searched from all reference fields pointing to sys_user isn't a problem, you should be able to modify the business rule from current.addActiveQuery() to current.addActiveQuery().addOrCondition("u_subcontractor", true);


(Assuming u_subcontractor is the name of the field)



Alternatively you can copy the business rule, mark the original as inactive and change the code so you don't own the OOB rule.


Thank you!   Using current.addActiveQuery().addOrCondition("u_subcontractor", true); worked perfectly.


Mark,


We have a similar issue where we would like users to be able to select inactive groups in a catalog item. I could not find a condition to reference the session table the user is on. Any ideas?