Sorting on a calculated business entity table field
 
Forums / SmartComponent Library - Developer Forum / Sorting on a calculated business entity table field

Sorting on a calculated business entity table field

5 posts, 0 answered
  1. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    01 Feb 2019
    Link to this post
    Hi!
    Was there a way to sort on a calculated field when using business entities? Is it even logically possible...
    Our use case is about a name field that has a too complex logic to be solved using queries. How about batching?
    Br,
    Patrik
    Last modified on 01 Feb 2019 08:02 by Patrik Wikström
  2. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    01 Feb 2019 in reply to Patrik Wikström
    Link to this post
    You need to translate the calculated field expression into a different data-source query. We have articles on the documentation site showing how you can manipulate the query after parsing the query string. 

    Alternative is to fetch all records to the client and use the JSDO's client side sorting (and batching) feature.
  3. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    01 Feb 2019 in reply to Mike Fechner
    Link to this post
    Could you point to the article, please? Say we have a procedure (yak!) fetchname.p that returns the name so I could somehow collect these into a temp-table that could be used as a datasource or how would that be solved?

    If we have something like this at the moment:
    eItemt
    - ItemCode
    - CalcFieldName

    The datasource table for eItem is our Item table.
  4. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    01 Feb 2019 in reply to Patrik Wikström
    Link to this post
    Instead of calling that procedure, you must be able to conditionally change the data-source query. Look for articles like "Filtering on a table that's not part of the default data-source" or similar. There are a few articles on Confluence on DATA-SOURCE related topics. 

    If that's not possible, you'll need to solve it through the JSDO.
  5. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    01 Feb 2019 in reply to Mike Fechner
    Link to this post
    Thanks, check that quickly and yeah, I think we can't solve this use case using that first approach.
5 posts, 0 answered