The CreatorCon Call for Content is officially open! Get started here.

Please help with Business Rule Script conditions.

Annie10
Tera Contributor

Hello,

Could someone please help review the code? It is not working. The purpose of the business rule is to allow users to see records that are assigned to their team, but not records assigned to other teams. Thank you.

 

When to Run:  Before, Query

Annie10_0-1715995405484.png

(function executeRule(current, previous /*null when async*/) {

if (!gs.hasRole("itil") && gs.getSession().isInteractive()) {
        var u = gs.getUserID();
        var qc = current.addQuery("requested_for", u).addOrCondition("opened_by", u).addOrCondition("watch_list", "CONTAINS", u).addOrCondition('assignment_group', '927934e41b6bf0104425cb35624bcbe9');
        gs.info("query restricted to user: " + u);
		current.addQuery('assignment_group', '927934e41b6bf0104425cb35624bcbe9');
    }

})(current, previous);

 

26 REPLIES 26

Hi @Annie10 ,

 

The data filtration rule is not about what specified users should not see, but more about what the general user should not see. E.g. if any user not part of the database team, the data filtration will work, and they will not be able to see the database tickets. 

 

if my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Hi @AndersBGS 

Thank you for the explanation. I learned some new things today.

AnimeshP_96
Tera Guru

@Annie10 
why don't you try ACL with security _admin role and not business rule, but still if you want to try then take all the conditions and put it in filter condition of the table list view and then add 
object.addEncodedquery()// to setup the user


for eg. if(gs.hasRole('itil')

{

current.addEncodedQuery('active=true');

})


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh

Hi @AnimeshP_96 

I would like to learn a method for filtering data. If you don't mind, could you capture a few screenshots so I can use them as a guide? Thank you.

@Annie10 
what you mean by filter?
can you give me any example so that i could tell you


Please accept the solution /mark this response as correct or helpful if it assisted you with your question.




Regards,
Animesh