Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to check view name using client script?

dianemiro
Kilo Sage

Hi,

I am trying to make a client script with the condition View == self_service and if true I want to set the state to Active. Here's my code but it is not working. Do you have any other way to meet what I am trying to do?

function onLoad() {

    //Type appropriate comment here, and begin script below

    var view = getView();

  if (view == 'self_service'){

  g_form.setValue('state','2');

  }

}

1 ACCEPTED SOLUTION

BALAJI40
Mega Sage
  1. function onLoad() {  
  2.     //Type appropriate comment here, and begin script below  
  3.     var view = getView();  
  4.   if (view == 'ess'){   //self service view name is ess so make to ess
  5.   g_form.setValue('state','2');  
  6.   }  
  7. }  

try this script.


View solution in original post

11 REPLIES 11

dianemiro
Kilo Sage

Thank you all for your help!!!


Nguyen Quang Tu
Mega Guru

Self Service is the title of the View. If you want to know the View's name, go to System UI -> View to see the name of the view