total records count in listcallback

303 views
Skip to first unread message

sivak...@gmail.com

unread,
Jan 3, 2014, 5:36:47 PM1/3/14
to suppor...@runmyprocess.com
Hi,

I am building a screen to display a collection data and I need to have a pagination with only 10 records being displayed on a page at a time.

Is there any option to get the total records count - I am searching a collection with some criteria using listcallback api.

I can build the pagination using the "nb" and the "first" parameters in the option but not sure how to get the total records.

Any help is much appreciated.

Thank you!!

Regards,
Siva

Regards,
Siva

sivak...@gmail.com

unread,
Jan 3, 2014, 5:49:47 PM1/3/14
to suppor...@runmyprocess.com, sivak...@gmail.com
It looks like there is a freemarker api - count_objects to get the total result count. I am looking for a similar API in javascript.

Thank you.

Regards,
Siva

Dimitri MELCHIOR Pro

unread,
Jan 13, 2014, 12:01:29 PM1/13/14
to RunMyProcess Support Forum, Sivakumar Venkatachalam
Hi Sivakumer,

When using listCallback to get data from a collection, you can pass options (2nd argument) which is a json. Have a look at these examples :

var options = {};

options.fields = ["firstname","lastname"];// retrieve objects with only   firstname and lastname fields. Default is []
options.mode = "TEST"; // retrieve data from the TEST or the LIVE collection.     Default is current mode
options.nb = 5; // max nb of items to list. Default is 100. Max is 1000.
options.first = 2; // starting index to list objects. Default is 0
options.orderby = ["lastname","firstname"]; //order by lastname and firstname. Default is []
options.order = ["asc","desc"]; //must match orderby : order by lastname asc and firstname desc. Default is []
options.asynchronous = false; //if you need synchronous requests, must be set as false. Default is true

 You will find all needed information into this user guide page : http://docs.runmyprocess.com/Developer_Guide/Collection/Collection_JS_Freemarker

Best regards.

--

Dimitri MELCHIOR

PreSales Consultant

     

Fujitsu RunMyProcess user? Please add a review on GoogleApps Marketplace

Afin de contribuer au respect de l'environnement, merci de n'imprimer ce message qu'en cas de nécessité.
Be environmentally friendly: do not print this email unless it is entirely necessary.



Regards,
Siva

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/ee4e1845-1843-4e44-9f92-cef88731a032%40runmyprocess.com.

sivak...@gmail.com

unread,
Jan 13, 2014, 12:45:40 PM1/13/14
to suppor...@runmyprocess.com, Sivakumar Venkatachalam
Hi Dimitri,

Thanks for your response. I am using the option parameter to control the result data. But for me to build the pagination, I need to know the total number of records that would be returned by the search query. For example, if my query returns 700 records, then I have to build 70 pages with 10 records per page. The option parameter will be helpful to build all those pages, but for me to come up with the pagination screen with 70 pages, I need to know the total records count.

There is a ${count_objects(object-pattern, collection-name)} Freemarker API. But I am looking for an equivalent Javascript API.

Please let me know if I am not clear.

Thank You!

Regards,
Siva

Dimitri MELCHIOR Pro

unread,
Jan 15, 2014, 5:00:49 AM1/15/14
to RunMyProcess Support Forum, Sivakumar Venkatachalam
Hi Sivakumar,

In case you want to count in javascript all the elements of your collection, you must use this code :

function callbackSuccess(result) {
alert("OK " + JSON.stringify(result));
}
function callbackFailure(result) {
alert("KO " + JSON.stringify(result));
}

var my_pipelines = [{$group: {_id: null,count: {$sum: 1}}}];
var my_options = {};

id_collection.aggregateCallback(my_pipelines,my_options,callbackSuccess,callbackFailure);

In case you want to count objects matching a special criteria, you must use that one :

function callbackSuccess(result) {
alert("OK " + JSON.stringify(result));
}
function callbackFailure(result) {
alert("KO " + JSON.stringify(result));
}

var my_pipelines = [{$match:{"key_1":"value_1"}},{$group: {_id: null,count: {$sum: 1}}}];
var my_options = {};
id_collection.aggregateCallback(my_pipelines,my_options,callbackSuccess,callbackFailure);

Best regards

--

Dimitri MELCHIOR

PreSales Consultant

     

Fujitsu RunMyProcess user? Please add a review on GoogleApps Marketplace

Afin de contribuer au respect de l'environnement, merci de n'imprimer ce message qu'en cas de nécessité.
Be environmentally friendly: do not print this email unless it is entirely necessary.



Regards,
Siva

--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
Reply all
Reply to author
Forward
0 new messages