Business rule(s) to enforce views

matthew_magee1
Giga Guru

Hi all,

I have created an additional view on sc_req_item and sc_req_item_list called ASK.

 

This view shows different columns than the SELF SERVICE view

 

I have 2 page, one to display all sc_req_items and the other page to display sc_req_items for a specific item (ask).

 

The views themselves work great, but when I start looking at these views through ESS, I get stuck on the ASK view in both pages.

 

We tried a view rule and it's not working too well.

 

My colleagues and are thinking of creating a business rule or two to help force a particular view on the respective pages.

 

Here's what I pulled off the wiki:

 

 

//Force non-itil users to the ess view for sys_user   
 //To use on other tables, replace sys_user with the table name   
 //Business rule: User View Filter //Table:global 
//Runat:server     
function sys_userGetViewName() { 
if (gs.hasRole("itil")) {return;
 }
 if (view.startsWith("ess")) 
{return;} 
// do not change view if it starts with sys_ (e.g. sys_ref_list)
 if (view.startsWith("sys_")) {return;} answer = "ess"; 
}     
function sys_user_listGetViewName() { sys_userGetViewName(); }

 

I'm not trying to base the views on roles, rather I just want to base the view on the page they pull up (orders.do or ask.do).

 

How would I write my business rule(s) to do this?

 

Thanks in advance-

2 REPLIES 2

matthew_magee1
Giga Guru

Follow up-


I had some 'junk' in my iframe that was setting the user pref. I removed it and things appear to be ok.


hi I have created an UI action in approver form..." UPDATE RITM",



function displayRITMRecord() {


        var dialog = new GlideDialogForm('Review & Update ', 'sc_req_item');


        dialog.setSysID(g_form.getValue('document_id'));


        dialog.addParm('sysparm_view','Approver');     ---- it works only for ITIL users and not for ESS users. So, used the below global business rule.


        dialog.addParm('sysparm_form_only','true');


        dialog.render();


}



created a global business rule as below to show the APPROVER view( in RITM )   to ESS approver when clicks on UPDATE RITM.




// populate the default value for the caller


function sc_req_itemGetViewName() {


      if (gs.hasRole("itil"))


  {return;}


  if (view.startsWith("approver"))


      {return;}


  if (view == "sys_ref_list")


      {return;}


  answer = "approver";


}


function sc_req_item_listGetViewName() {


sc_req_itemGetViewName();


}



I dont see any luck in getting my APPROVER view shown to the end user through UI Action. Kindly help