How can I get the returned result count from a search (Searc

Posted by ByronB on 29-Jan-2015 12:20

Hi, I am trying to get the amount of returned results from a search. What is the best way of achieving this?

I have tried counting the returned table rows but is inconsistent between returned results and no results found.

I tried this as a test:

rbf_getCount2(10930, 'starts with', 'Micro', function cb(values){alert(values.length);});

but get undefined as a result. 

Posted by Orchid Corpin on 30-Jan-2015 10:06

1. Edit the list view and go to "Totals and Subtotals" section > Specify the object name for counting.

2. After saving the list view this will add new rows at the bottom part says Grand total, beside it the # or record rows in the list. Now, in your search result page specify the code below.

<script>
$(document).ready(function() {
		var x = $("tr.listItem:last td.rbs_listSummaryNumber:eq(1)").text();
		if(parseInt(x) > 0) {
			alert("There are results: "+x);
		}
		else {
			alert("NO results: "+x);
		}
});
</script>

---------------ANOTHER WAY---------------

If you don't need the # or rows and just simply identify whether there are results, you can use the code below into your search result page.

<script>
$(document).ready(function() {
	var x = $("tr.listItem").length;
	if(x > 0) alert("There are results");
	else  alert("NO results");
});
</script>


Hope this may help.

Regards,
Orchid

All Replies

Posted by Orchid Corpin on 29-Jan-2015 12:56

Hi Byron,

You mean amount is a decimal field and when doing search you want to get the total of its column?

Regards,

Orchid

Posted by ByronB on 29-Jan-2015 13:12

Didnt explain well, functional example:

On Account --> Records List Account I have a detailed search, after searching you get redirected to the Search Results Account page with list of matches. I want to count the number of rows returned and do something if there are no results returned and something else if there are results returned. Basically a record count.

Posted by Orchid Corpin on 29-Jan-2015 13:56

I see, you have to create a detailed search too in the search result page then by code get the value of the field being filtered and assign that value the rbf_getCount2.

- Below image is a search result page, I also specified a detailed search above the list.
- When a user click the search button it takes over the value in the search field so there you assign that value the getCount. See code below, it works for me.

Note: It only works for "equal" and not for "contains"

<script>
	var filterVal = $("input[name='opValueDet1']").val();
	rbf_getCount2("137279", "product_code", filterVal, function(data) {
		alert(data);
	});
</script>

Hope this may help.

Regards,
Orchid

Posted by ByronB on 30-Jan-2015 01:15

Thanks Orchid

Would there be an alternate solution for "starts with" or "contains" as we do not have one condition with "equal" as exact match searching isnt practical. I just really want the number or rows returned and display a message accordingly.

Posted by ByronB on 30-Jan-2015 01:22


Here is our scenario:


Accounts:



After searching you get redirected to the Search results:



Now if there are no records to display (as above) then I would like to display a message with a different button, if there are results I would like to display a message with the above button.



[collapse]
From: Orchid Corpin <bounce-ocorpin@community.progress.com>
Sent: 29 January 2015 18:57
To: TU.Rollbase@community.progress.com
Subject: RE: [Technical Users - Rollbase] How can I get the returned result count from a search (Search Results page)
 
Reply by Orchid Corpin

Hi Byron,

You mean amount is a decimal field and when doing search you want to get the total of its column?

Regards,

Orchid

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Orchid Corpin on 30-Jan-2015 10:06

1. Edit the list view and go to "Totals and Subtotals" section > Specify the object name for counting.

2. After saving the list view this will add new rows at the bottom part says Grand total, beside it the # or record rows in the list. Now, in your search result page specify the code below.

<script>
$(document).ready(function() {
		var x = $("tr.listItem:last td.rbs_listSummaryNumber:eq(1)").text();
		if(parseInt(x) > 0) {
			alert("There are results: "+x);
		}
		else {
			alert("NO results: "+x);
		}
});
</script>

---------------ANOTHER WAY---------------

If you don't need the # or rows and just simply identify whether there are results, you can use the code below into your search result page.

<script>
$(document).ready(function() {
	var x = $("tr.listItem").length;
	if(x > 0) alert("There are results");
	else  alert("NO results");
});
</script>


Hope this may help.

Regards,
Orchid

Posted by ByronB on 30-Jan-2015 10:14

Very nice thank you :-)

Posted by Orchid Corpin on 30-Jan-2015 10:32

You're welcome!

Cheers,

Orchid

This thread is closed