HHow to get list view name in script include

kannann_
Kilo Expert

Hi All,

I have created a script include "taskDisplayFilter" to hide/show filter on the task table, I want to show/hide the filter based on the current view, but I am not able to get the current view name inside script include. Can you please help me out?

1 ACCEPTED SOLUTION

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();


      }


  }


View solution in original post

5 REPLIES 5

Christine30
Tera Guru

Hello:  I have a similar question.  The code works for me when called when a form is loaded. What I'd like to do is use the view to restrict the records that appear when the list is loaded, but at that time the view does not appear to be populated.  This is what I have in a before query business rule on alm_hardware.  I'd appreciate any help.  

(function executeRule(current, previous /*null when async*/) {

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

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

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

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

           }

           if (view_name == 'XYZ') {

                 current.addQuery('install_status', '!=', 21); 

// Unfortunately, this does not restrict the records shown in the list view (alm_hardware.list), which is what I'd like.  It does restrict the records that can be accessed from the list view (when I click on a record with install_status equal to 21 I receive "Record not found").

           }

})(current, previous);