filter is not working on task report data

Certified Lead Developer
I am trying to use work with below snippet, the filter is no applying on process analytics.
With or with out filter is giving me the same result.Here filed "c8" contains Assigned To values for the task(i.e user(s) /group(s)).
Here I am trying retrieve the tasks assigned to particular group /(user),but it is fetching all the tasks.
a!queryProcessAnalytics(
          report:cons!TASK_REPORT,
          query:a!query(
                    filter:a!queryFilter(field:"c8",operator:"includes",value:togroup(876)),
                    pagingInfo:topagingInfo(1,-1)          
          )
)

OriginalPostID-244965

  Discussion posts and replies are publicly visible

  • Hi @Rama,Can you check by using "=" operator in query filter. That might resolve thus.
  • The Assigned To is a list of User or Group. Using "=" will not match a task that is assigned to group 876 and something else. Try to change column c8 to be of type list of String (using touniformstring) and casting the group to a String as well (using tostring(togroup(876)) for instance). If this works, then you can investigate why the filter does not match on the correct types.
  • Basically in your portal report, you need to convert the type of assigned to as, joinarray(tp!assignee,";")
    And then the above filter should work......... Let me know if you need any other assistance.
  • I would like to add few things here out of my experience:
    1. "=" operator isn't the right criteria as per my knowledge. This holds good only if the value is of type single. If we would like to apply it for values that are of type multiple, then the valid operator to be applied in 'logicalExpression' is 'AND'. This means that we can get only those rows that has the task assignees as the inputted filter value and we will miss the use case - 'Get me any of the rows that has task assignees among the inputted filter value'. Still if we would like to go with "=", we need to align the data properly, that is, the order in the Portal Report and the Filter Value should be the same, this is because, as we are sending the lists, and matching it with a list in each row, their order, formatting, delimiters should be completely same in order to get the matching rows.
    2. fn!joinarray() can't be applied directly because this results in formatting of the Group as [Group:<group_id>] which becomes tough while applying filters. Again this requires the filter value to be formatted in case of Group which isn't really needed provided if we properly format the values in the report itself. This applies only in case of '=' operator.
    3. And finally I would like to add that a single query filter against the Assignee column isn't sufficient to accomplish the use case properly as per my knowledge. If we use a single use case, we would be left with accomplishing the use case with following drawbacks:
    a. We miss the use case where we need to get a task provided if the task assignee is any one of the filter values
    b. We need to sort the report data prior to formatting the data (i.e. applying joinarray() in the Task Report) and also should sort the data in the filter value. And then, even the delimiters applied in both the places should be the same. This is because matching a list with list should be the same in terms of order and the delimiter as well.
    c. Afaik logic of applying single filter deifies when the filter value is a combination of multiple values and complicates the filtering even if it's possible.

    @ramanjaneyulut I have devised a approach which will allow to filter the task assignees in the Report irrespective of the type or values(can be a User, List of users, Group, List of Groups, List of Users and Groups). Also, applying an OR operator gives you the list of tasks in which the filter values are individually or together a part of, and applying the AND operator gives only those tasks that the filter values are together a part of.

    Attached a document and application(well documented to maximum extent). Let me know if you have any questions in case if you try the approach attached be me here.

    PC Search task assignees.zip

    PC Search task assignees.docx

  • @sikhivahans
    Hi ,

    Thanks for the approach shared for filtering users/groups in tasks it was really helpful

    For this use case I have followed a different kind of approach

    I have created a rule (DataSubset , ColumnNumber (Integer), searchString(Text))
    This rule takes in the dataSubset , and also the columnNumber of the task in the report, along with the searchString (username or groupID as [Group:890] )

    I then used a whereContains with the searchString for that particular row assignees , by converting them into a string and splitting them , which returns true or false based on the match found

    I am not sure how this is good with respect to the performance and best practise

    It would be helpful if you can please suggest me how far this might be effective , in terms of huge amounts of data

    Thanks
  • @shashankb I should say that the search isn't straight forward as per what you have described. There are few things as follows which you will need to consider:

    1. You need to split the task assignee information from the report. And then you would be searching using wherecontains(). And moreover you will be applying the search rule iteratively over each record in the datasusbset and then need to build a new datasubset. I believe this imposes burden and may not be great when compared to querying by making use of query filters.
    2. How are you obtaining the data from report? All records or only a few? Let's say I have 1000 records and want to get only 10 records at a time based on the pagination. Let's say we have got 10 records and passed all the 10 records to search rule. What if the search rule returns less than 10 records by disqualifying others? So for this to implement, you should be querying all the records in the first place, that is, make use of batch size as -1 and then apply your search rule, build a new dataset and then finally we need to paginate the new dataset. I believe querying the report with a batch size of -1 is not appreciable and won't work in all cases. And also there isn't a need to get all the records, as in most cases the number of records you show in task report won't be more than 25.

    Finally I opine that searching for the data in a dataset(that too fetching the entire dataset) may not be a wise idea when you already have the ability to apply filters and get the required data.
  • @sikhivahan
    Yes as you said I am fetching all the records by using -1 as batch size , even I was thinking the same regarding load when bulk records come into picture

    Thanks for the opinion

    Will go forward with the way of filtering tasks mentioned by you earlier

    It was helpful
  • 0
    Certified Lead Developer
    @sikhivahans
    Quick update: It is working perfectly. Many Thanks
    Will update if any improvements needed.
  • @ramanjaneyulut Perfect, I have submitted it for internal review to my employer. If I hear any feedback, I will keep it posted here.
  • I wonder if I could ask a question related to the code shown in PC Search task Assignees.docx.

    I have been attempting to get this to work but have a problem. When I generate the queryFilter as "
    [field=c16, operator=includes, valueExpression=, value=paul_emsley@johnlewis.co.uk]" (ie for a User) it works fine.

    When I generate the queryFilter as "[field=c17, operator=includes, valueExpression=, value=[Group:2920]]" (ie for a Group) it does not work:
    [startIndex=0, batchSize=0, sort=, totalCount=0, data=, identifiers=, name=, description=, columnConfigs=, errorMessage=There was an error querying the Analytics report. (APNX-1-4275-000)]

    I can&#x27;t find any documentation about this error. The Appian stdout log shows:
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) 2017-05-08 12:15:26,173 [ajp-/0.0.0.0:8009-15] ERROR com.appiancorp.expr.server.fn.query.QueryProcessAnalytics - java.lang.Long cannot be cast to java.lang.String
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) at com.appiancorp.record.data.bridge.FilterHandler$FilterOperatorIncludes.toSimpleColumnFilter(FilterHandler.java:196)
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) at com.appiancorp.record.data.bridge.FilterHandler.criteriaToFilters(FilterHandler.java:61)
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) at com.appiancorp.record.data.bridge.FilterHandler.criteriaToFilters(FilterHandler.java:74)
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) at com.appiancorp.record.data.bridge.FilterHandler.criteriaToFilters(FilterHandler.java:51)
    12:15:26,175 INFO [stdout] (ajp-/0.0.0.0:8009-15) at com.appiancorp.expr.server.fn.query.QueryProcessAnalyticsValidator.validateAndSetReportFiltersFromQuery(QueryProcessAnalyticsValidator.java:102)

    However, if I use the operator "=" instead of "includes", it works, providing my tasks have a single group assigned. Where I have multiple groups assigned, the filter does not show those tasks. So I need the "includes" to work.

    Any suggestions?