Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Splitting query output

Forum

Search UsersRules
Splitting query output
#1
Interested
Points:: 15
Joined:: Oct 27, 2011

Hello, I am trying to use 1C:Enterprise as a backend for my project. I need to present some search results in pages.

How to split the search results into pages? (like page 1, page 2, page 3...)

When the user searches for products on my project website, I want results to be split into several pages showing around 20 results per page. The search results are the outcome of database query.

For example: If the user searches for Samsung mobiles so my query will be:

SEL ECT * FR OM PRODUCTS WHERE BRAND='SAMSUNG';

Suppose the above query returns 55 results, how to show them into pages (1,2 and 3)?

How could I use internal caching? Are there any best practices? Should I store temporarily the result during user session? Could this be done automatically?

p.s I do not want to send all results to the client. It could take some time (could be 200 pages)

Profile
#2
Interested
Points:: 0
Joined:: Dec 4, 2017

Dear Alexey,

We are preparing an answer for you and will return back soon with it.

Best regards,
Vladimir Gurov

Profile
#3
Interested
Points:: 15
Joined:: Oct 27, 2011

Vladimir, I have tried to perform it via OData, but if I connect to the same infobase it hangs.
I can not connect to the OData interface directly, because it seems like it does not have rights restriction I need.

Profile
#4
Active user
Points:: 0
Joined:: May 8, 2013

Hello Alexey,

There is nothing ready-to-go in the platform for this type of tasks, but you have many different options for implementing this functionality yourself.

The most natural one is to show the list in a specific order and download next/previous page adding a condition > or < for the order key fields.

Say, you have attribute KEY_FIELD in the table and show the list in its order by 20 items per page. You first-page query will look like this:

SELECT TOP 20 * FROM PRODUCTS WHERE BRAND='SAMSUNG' ORDER BY KEY_FIELD

After you received this page you should save the last KEY_FIELD value and use it as a condition when you download the next page:

SELECT TOP 20 * FROM PRODUCTS WHERE BRAND='SAMSUNG' AND KEY_FIELD > &LAST_KEY_FIELD ORDER BY KEY_FIELD

You can choose where to implement this - in your app or on the 1C server side.

If you're implementing it in your app, you definitely don't want this kind of functionality to work in a browser. So you will need a site backend (some NodeJS application or whatever) to handle this pages loading and switching. This NodeJS code should request data through REST API.

You also could implement this page-switching logic on the 1C server side (using 1C script language). Then you can publish your own API as a SOAP service (1C web service) and request it from browser JS directly if necessary.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.