How to get View Name on Server side UI ACtion

hima6
Mega Expert

Hello,

i want to get the view name on UI action(Server Side). is there any function for that ?

Regards,

Hima Pallela.

1 ACCEPTED SOLUTION

Abhinandan Pati
Giga Guru

Hi Hima,



Try below code snippet.



var view_name='';


if (gs.getSession().isInteractive()) {


      var map = gs.action.getGlideURI().getMap();


      if (map.get('sysparm_view') != null) {


      view_name= map.get('sysparm_view').toString();


      }


  }


gs.log('View: '+view_name);



Thanks,


Abhinandan


View solution in original post

9 REPLIES 9

var gURI = new GlideURI();

var viewName = gURI.get('sysparm_view');

Nick65
Mega Expert

OR


gs.action.getGlideURI().get('sysparm_view') == 'my_view';


rishireddy
Mega Guru

There might be the issue with gs.action.getGlideURI().getMap().get('sysparm_view'); in Istanbul release



We can get the view name in business by just using 'view' because 'view' is a global variable that holds the current form view.



Eg:


On 'Display' type Business rule at TOP domain mention in script as,


if(view=='ess' && !current.isNewRecord()){


DO YOUR ACTION!!!


}



Please Hit Like/Helpful based on the response, so that it may help others to quickly find a solution for related issue



Regards,


Rishi


Hey.

"We can get the view name in business by just using 'view' because 'view' is a global variable ..." - where comes that from?

Unfortunately this seems not to be the case ;-(

I'm currently looking to get the view on a on before business rule without using  gs.action.getGlideURI().getMap().get('sysparm_view') due to issues that comes with it.

 

Any idea?

Thank you.

dmitry_a
Tera Contributor

Hello,

The following code seems to be working in San-Diego:

var view;
if (gs.getSession().isInteractive()) {
 var map = gs.action.getGlideURI().getMap();
 if (map.get('sysparm_form_view') !=null)
  view = map.get('sysparm_form_view').toString();
}
gs.info('view = ' + view);