View rule issue

MMKK
Tera Expert

Hi All,

 

All users are redirected to Self Service View. I do have a view rule as shown below. However, still the user is having self service view selected as default.

 

var user = gs.getUserID();
var users = new GlideRecord('sys_user_has_role');
users.addQuery('user', user);
users.addEncodedQuery('role=319665eddb695b0005d2147a3a96194d');
users.query();
while(users.next()){
gs.addInfoMessage("changing the View");
view = 'test_view';

1 ACCEPTED SOLUTION

Checkout the Global Business Rule named incident functions

In the script you will find a function incidentGetViewName()

Make your coding changes in the function, this function is responsible to redirect you to ess by default

// populate the default value for the caller
function incidentGetViewName() {
  if (gs.hasRole("your role name")) {
     answer = "YOUR_VIEW_NAME_HERE";
     return answer;
  }
  if (gs.hasRole("itil"))
     return; 
  if (view.startsWith("ess"))
     return;
  if (view == "sys_ref_list")
     return;

  answer = "ess";
}

 

Reference: 

View rules on Incident Table

View solution in original post

10 REPLIES 10

ARG645
Tera Guru

Try this,

var user = gs.getUserID();
var users = new GlideRecord('sys_user_has_role');
users.addEncodedQuery('user='+user+'^role=319665eddb695b0005d2147a3a96194d');
users.query();
while(users.next()){
gs.addInfoMessage("changing the View");
answer= 'test_view';// set the new view to OOB answer variable
}

No luck. Actually, i tried to place a log in teh begining of the script. It did not work. ANy reason?

If your gs.log statement did not work, then it might be something silly. 

Did you select the Table in your View rule ?

Is your View Rule Active?

Please past a screen shot of your view rule so that it will help us to resolve your issue. 

MMKK
Tera Expert

Here it is:

 

find_real_file.png