I am using queryEntityData SAIL tag to retrieve the data from database and calli

I am using queryEntityData SAIL tag to retrieve the data from database and calling multiple time based on the different inputs(using apply function) . I want to display this record details in the Single Grid. how can i merge result and display the same on the Grid?


Thanks in advance.

OriginalPostID-211650

OriginalPostID-211650

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer
    Hi, I would recommend using a!queryLogicalExpression (forum.appian.com/.../System_Functions.html to query based on multiple inputs, as opposed to using apply to loop over a query. This will not only be faster, but it'll also return all of the data together without having to do any kind of merging. Hope this helps!
  • 0
    Certified Lead Developer
    Have a look at using todatasubset() function on your array of .data values
  • @ramakg You may do something as follows:

    fn!load(
    \tlocal!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 5,
    sort: a!sortInfo(
    field: "",
    ascending: true()
    )
    ),
    \tlocal!data: ,
    \t/* Data obtained by querying entity in an iterative manner or data obtained by merging the query entity results. Make sure that a!queryEntity().data for each query is finally merged while forming the resultant array. */
    \t
    \t/* Replace myCDT in the type!myCDT() with the name of the CDT which you have been using. */
    \tlocal!myCDTData: fn!cast(
    \ tfn!typeof({type!myCDT()}),
    \ tlocal!data
    \t),
    \t
    \t/* Paginate the local!myCDTData and provide the same to the Paging Grid */
    \t
    \t
    \tfn!with(
    \ tlocal!myCDTDataSubset: fn!todatasubset(local!myCDTData,local!pagingInfo),
    \ t/*
    \ tPaging Grid that surfaces the data from local!myCDTDataSubset
    \ t*/
    \t)
    )

    But I believe that you will get suggestions from the practitioners re the iterative application of query rule. As per my experience, I know that, some times it's inevitable but I would suggest to stay away from it as much as possible.
  • the requirement is forcing me to execute the query multiple times. for where condition I am using different rule and it takes some input(passing and getting the value)
  • @ramakg True that it's inevitable at times, but in-case if you feel that there is a chance to overcome it, elaborate the scenario in detail so that the practitioners here might come up with resolution mechanisms. It seems like you might get good amount of data as you are going for paging grid, which means that there would be lot more queries, and so keep an eye on the performance.
  • One of the way would be to create objects on the fly using apply loop on different result sets from different entities using either type! Or {name:"abc"}. Just append all the objects and display the data in grid. I still recommend using logical expressions to avoid performance bottlenecks.
  • @ramakg - What you can do is after you have gathered all data from the db using apply, you can merge all the data using what we call an Anonymous CDT which is of type dictionary and then change it into a datasubset using todatasubset() function.
    We do it for reporting because if the data comes from different tables then it is hard to sort. So we create a Anonymous CDT and merge then to one datasubset and the use it in a grid. Please make sure to use constant paginginfo throughout or else there might be some paging or sorting problem.

    For example:
    todatasubset(
    \t{
    \t firstName:"Sidhant",
    \t lastName:"Behura",
    \t gender: "Male",
    \t age:"24"
    \t}
    )

    Hope this information was helpful.
  • An anonymous/formatted CDT or a label-value pair (such as {{name:"john.doe"}}) would be helpful if and only if the queries are being made on more than one data store entity.

    Else a simple type casting is more than enough and what we choose (i.e. type casting/ formatted or anonymous CDT/label-value pair) should depend on the situation.
  • I want to display latest document uploaded by the user based on some context. What I am doing here is before inserting the document I am getting the latest version and inserting it into the database. this is working fine. now I want to display latest document uploaded by the user on the dashboard based on context. for this I am getting the latest version based on the context before getting the document details. let me know is there any better approach other than this.

    Note: using the same table to capture doc details and version.