How to get the view name of the form by using script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2014 03:41 AM
Hi All,
For change table we are having two different views.So I want to get the view name by using script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 06:53 AM
There should be a feild in either of the views that is not being used in another view and is mandatory in one view.
If you have a field say 'IPv4' for view = default and is mandatory => all record created from this view(default) will have some value.
Similarly, you have a feild name 'IPv6' for the other view which is mandatory and only used in this view.
Considering the above two factors are correct, you can add a filter in the module saying:
IPv4 IS NOT EMPTY (this will be for default)
IPv6 IS NOT EMPTY (this will be for the other view)
You dont need to do any scripting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 07:09 AM
If I understand your requirement correctly, all you should be be doing is prefixing your filter with '&sysparm_fixed_query' in the arguments field in the module record.
For module1: &sysparm_fixed_query=u_change_type=itcc
For module2 : &sysparm_fixed_query=u_change_type=Infrastructure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-16-2014 09:41 AM
Yes your right...but i don,t want to show that filter on list view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2014 03:41 AM
try something like this .....
var transaction = GlideTransaction.get();
var page = transaction.getPageName();
gs.log("Page is ====>" + page);
//page = view_name
if (page == "itcc"){
current.addQuery("u_change_type", "itcc");
}
if (page == "default"){
current.addQuery("u_change_type", "Infrastructure");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-22-2014 04:12 AM
getPageName() is just telling what kind of view it is like for example incident_list etc . But to capture the actual View name then use the below .....
var transaction = GlideTransaction.get();
var ViewNameIs = transaction.getRequestParameter("sysparm_view");
gs.log(ViewNameIs);
Now based on the View name you can update your query