Is there a way to identify via Script, that user has opened a List view or Form View?

Pawan Kumar Sin
Tera Contributor

Hi Team,

 

Is there a way to identify if user has opened a form view or list view ? Just like ,we can check whether user is from interactive session gs.isInteractive() using GlideSystem Method. 

 

Problem Statement:

Actually we have problem with Query BR, which works both on form and list view (Obvious behavior of Query BR)? and it is unnecessary run a query BR on form view to do a complex query, if we are just opening single record. So we would like to update Query BR condition to not to run on form view. Any alternative idea is also welcome in this Problem statement

 

Regards

Pawan K Singh

1 ACCEPTED SOLUTION

Anwesha3
Mega Guru

Hi @Pawan Kumar Sin,
Hope you are doing well. 

You can try fetching the URL and check if the URL contains "_list". If it returns true, then it should be a list view. 

Sample: if(url.indexOf("_list")>-1) 

Please mark this response as correct or helpful if it has helped you with your question. 😊

Thanks, and regards,
Anwesha 

View solution in original post

2 REPLIES 2

Anwesha3
Mega Guru

Hi @Pawan Kumar Sin,
Hope you are doing well. 

You can try fetching the URL and check if the URL contains "_list". If it returns true, then it should be a list view. 

Sample: if(url.indexOf("_list")>-1) 

Please mark this response as correct or helpful if it has helped you with your question. 😊

Thanks, and regards,
Anwesha 

Pawan Kumar Sin
Tera Contributor

Thanks Anwesha for an Idea, I tried below script condition on BR, to not to work in form view and it is working.

 

var runBROnFormView = true;
var currentURL = gs.action.getGlideURI().toString();

if (currentURL.indexOf("_list.do") > -1 ) {
runBROnFormView = false;
}

if(runBROnFormView) {
// Execute Form view Script
}
else{
// Execute List view Script
}

 

Regards

Pawan K Singh