How to get the view name of the form by using script

mdsannavulla
Kilo Guru

Hi All,

For change table we are having two different views.So I want to get the view name by using script.

32 REPLIES 32

Kalaiarasan Pus
Giga Sage

Client Side


http://wiki.servicenow.com/index.php?title=Client_Scripts


Section 4.8.11 Show or hide an action button depending on the form view



Server Side


http://wiki.servicenow.com/index.php?title=Restrict_Form_Views_by_Role


Hi Kalai,



Below is the code I am using for querying different views,but it is not working



if (current.getEncodedQuery().indexOf('sys_id>')== -1)


  {



  if (current.getEncodedQuery().indexOf('sys_id=') != 0)


  {


  if(view.startsWith("default"))


      {


  current.addQuery("u_change_type", "Infrastructure");


  }


  else if(view.startsWith("itcc"))


      {


      current.addQuery("u_change_type", "itcc");


  }



  }


}


Haven't used it much .. try it on demo and work out something simple first .. if that works well, try to built on it .......


The DOM does not contain an element with ID = sysparm_view