I have a viewpanel in an XPage that has its search value "Search in Search Results" set to a sessionScope variable called queryString. it is set with the following formula...
var tmpArray = new Array("");
var cTerms = 0;
if (sessionScope.SearchTourArea != null && sessionScope.SearchTourArea != "") {
tmpArray[cTerms++] = "(Field TourArea = \"" + sessionScope.SearchTourArea + "\")";
}
if (sessionScope.SearchTourRegion != null && sessionScope.SearchTourRegion != "") {
tmpArray[cTerms++] = "(Field TourRegion = \"" + sessionScope.SearchTourRegion + "\")";
}
qstring = tmpArray.join(" AND ").trim();
sessionScope.queryString = qstring;
return "Query = " + sessionScope.queryString
Within the view, in the "Search in search results" I use the formula;
return sessionScope.queryString;
This all works and returns the correct results, however my problem is that it seems to remember this sessionScope variable, so if I include the following code, it will open the page saying there are "34 tours found that suit your choice" when i haven't yet set the search criteria.
if (getComponent("viewPanel1").getRowCount() == 0){
return "Sorry, we dont yet have any Tours for this combination. Please change some of your choices"
} else {
return getComponent("viewPanel1").getRowCount() + " tours found that suit your choice"
}
I'm at a loss. I think all i need to do is reset the sessionScope variable to "", but dont seem to be able to do it.
thanks in advance,
sessionScope.queryString
being set. Please add that information and/or confirm the code is being run again when you expect it to. – Paul Stephen Withers