how to retrieve view in business rule

cc_lee
Kilo Explorer

Hi All

Anyway to retrieve view name in business rule? I tried current.view.name, view.name, sysparm_view.. but all cannot get the view. Anyone one can help?

Thank you.

9 REPLIES 9

bennyb
Kilo Contributor

I would greatly appreciate this too!

I have tried these to no avail:
var view = sysparm_view;

I need to get the view so I can perform some logic to set a reference qualifier as per:
http://wiki.service-now.com/index.php?title=Reference_Qualifiers#Advanced_Reference_Qualifiers

If the view is ess, then I only want to show certain things in my reference field.

Trying to get the view from a global business rule is turning out to be very challenging - any help appreciated!


Ramkumar Rajend
Tera Expert

If I am not wrong the following code will help to check for the view names in Business rule and based on the name we can derive the action.



if (view.startsWith("ess"))


        return;


  if (view == "sys_ref_list")


        return;


jadona
Giga Contributor

var current_view = RP.getParameterValue('sysparm_view');



or



var current_view = RP.getViewID();



should work.


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


HI javier,



Can you suggest me the view of the parent table in ui action.



Thanks,


Swati