Views and View Rules

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi guys,

i have one basic question,

i read articles on wiki about View and View Rules.

But i am not getting exactly how can i have someone view a specific view.

i have one view on incident and i want it to be viewed by one particular user with particular role.

For ex: if i have role abc, he should view xyz view.

1 ACCEPTED SOLUTION

paramveer
Mega Guru

Suppose you don't want ITIL role   users to show the Urgency field on incident form.



Then go to access control --> create new


ACL Name : Incident.urgency, Operation Read check advance.



In script write :


if(gs.hasRole('ITIL') {


answer = true;


}


else {


answer = false;


}



find_real_file.png


View solution in original post

14 REPLIES 14

paramveer
Mega Guru

Hi Ashutosh,



Then you can achieve the functionality by onload client script.



we have "switchView" function to Achieve that.



switchView(type,table,view);



The table and view parameters should be self explanatory. The 'type' parameter is either 'list' (to redirect to a list view) or 'section' (to change to a form view). Here's an example client script that shows how you could use 'switchView' to change the incident form view to 'ess' if the 'Category' field changed to a value of 'hardware'.



function onLoad() {


                //Change to the 'ess' view if the Category is 'Hardware'


                if(RoleMatching){


                      switchView('section','table_name','view_name');


                }


joee1
Kilo Contributor

I'm using a switchView similar to the one above, and I'm having a problem because of the fact that it runs onLoad. I want the user to see a specific view by default, but have the ability to switch to a different view if they'd like. However, using the dropdown to change views re-loads the page, causing the switchView to execute. As a result, the user is forced to only ever see the view defined in the script.



Is there any way around this?


Hi Paramveer,

 

Can you please help me creating a code. I want to switch a view when I select CI (Configuration Item).

So if my Configuration item is "Project" my incident should switch into Project form.

 

Please advise.

 

Thank you in advance.

@paramveer - I've tried this but for some reason, I'm stuck on an infinite loop. I'm using an onload client script and I'm checking the Assignment Group of the record. Is there a way to check which is the current view so I can add a condition for it? Thanks!

Greg42
Mega Guru

Hi All,



Just to quickly chip in to anyone interested of how to do it in Eureka using Business Rule:



// table_nameGetViewName


function cmdb_ci_serviceGetViewName() {



          if (your condition here) {


                    return (answer = "your_view_name");


          }



          answer = "default";


}



// table_name_listGetViewName


function cmdb_ci_service_listGetViewName() {


          cmdb_ci_serviceGetViewName();


}




Cheers



Greg