Client Script applying only on 2 views?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 02:19 AM
Hi,
I want to apply one of my client script only on two views-- default and text_search view.
For default i understand giving blank it works and for text search its name. But i have to do for both the views. Is there any way we can do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 02:28 AM
Hi Sarfraz,
Get the view name in the client script and execute your client script code based on the view on which you want it to run
var viewName = getView(); // returns the view name
// for default view this returns as empty
if(viewName == 'text_search' || viewName == '')
{
}
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-23-2017 03:00 AM
Hi ankur,
i tried this, but since we are using onSubmit, if we change view then it is taking the new selected view.that is the error we are getting basically, while changing the view.
SO, my question is how can we give it by unchecking the global and defining view name in the client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2020 02:57 AM
did you try creating a view rule?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-07-2020 03:44 AM
Hi Sarfraz,
Please check this link below
https://www.servicenowguru.com/scripting/client-scripts-scripting/change-form-view-client-script/
if this helps please mark correct or helpful.
Thanks
Swapnil