Matching values in list field using query

Alon Grod
Tera Expert

Hi,

I am trying to prevent from specific users to see articles in KB by using their exclude and include Account. The goal is to let them see only articles that their account is empty, or the user's exclude account is not in the article's account.

For example, ex_account list will include [A,B]. 

                       in_account list will include [C,D,F].

If the article's Account contain:  [B]. The user will not be able to see the article.

If the article's Account contain: [Z,P]. The User will be able to see the article.

If the article's Account contain: []. The user will be able to see the article.

What am I doing wrong?

(function executeRule(current, previous /*null when async*/ ) {
    var ex_accounts;
    var in_accounts;
    
    var gr = new GlideRecord('sys_user');
    gr.addEncodedQuery('sys_id=' + gs.getUserID());
    gr.query();
    while (gr.next()) {
        ex_accounts = gr.u_exclude_account; //excluded accounts in user record
        in_accounts = gr.u_include_account; //included accounts in user record

    }


        query = 'u_accountISEMPTY^NQu_accountLIKE' + in_accounts + '^NQu_accountNOT LIKE' + ex_accounts;
        current.addEncodedQuery(query);

    

})(current, previous);

5 REPLIES 5

@Alon Grod any luck with the above script ?

if it worked please close the thread by marking the answer correct so that it goes to solved queue