How can I get all the tasks where loggedInUser is an Assignee

Certified Senior Developer

Have a task report with an "Assigned To" column which can have multiple users based on the task type.

Using queryProcessAnalytics() in one of the task reports to get the tasks where logged in user is a part of the assignees.

Using the following query filter :
a!queryFilter(field:"c1",operator:"includes",value:loggedInUser()),

But its not working as expected. How can I get all the tasks where loggedInUser is an Assignee.

Thanks in advance.

OriginalPostID-216672

OriginalPostID-216672

  Discussion posts and replies are publicly visible

  • In queryProcessAnalytics() function, passing loggedInUser() as the value to ContextUsers parameter would list only the tasks of logged in user.
  • 0
    Certified Senior Developer
    Yes it can. But our requirement is to get the tasks for particular set of process models. For that, we have used contextProcessModels in queryProcessAnalytics(). It doesn't allow me to use both contextProcessModels and contextUsers parameters together.
  • @vikrantb To the best of my knowledge, whatever you have been trying is not possible.

    But you can opt for an alternate way as mentioned below:
    1. Create a Task Report which gets the Tasks based on User Context and add the Process Model Id (pm!id) in the Report as a column.
    2. Use a!queryProcessAnalytics() with the desired users as the contextUsers argument and apply the desired process model ids as filter by making use of filters argument.
    3. As there could be a possibility of getting duplicate results(as the group tasks are open for all the users), discard the duplicates from the resultant dataset and the resultant dataset minus duplicates is the actual result what you are looking for.

    Until and Unless I miss something, above mentioned approach should do the job as per my knowledge.
  • As said by Sikhi there should be two Task Report created

    1)One the data u look for
    2)Create a context attributed to user

    In both reports add one column task id in it. So in your sail code pass the you need to add two datasubset

    One for User and One for your actual report. To both pass the value as loggedinUser and u will be getting task id from both datasubset. Use the integration function to make task id's unique and you can pass the task id to third datasubset which should be like below

    a!queryFilter(field:"c1",operator:"includes",value:local!selectedTaskId)

    This should work for you....
  • I would like to make a confirmation here on what I have mentioned earlier as I see in the last comment that it's interpreted in a different way than intended:

    I should say that two reports aren't needed at all. We just need only one Portal Report and this Portal Report should be able to get the Task Information based on User Context(to be specific, 'Tasks Per User' category). Along with the Task Information, the Report should also hold Process Model Id (with pm!id as value) as a column. Attached a screen shot which says how the basic contents in it should look like. And here's how we write the query to accomplish the use-case discussed in this post by @vikrantb.


    fn!load(
              local!contextUsers:{},
              /*Populate the local!contextUsers with the desired users. Example: fn!touser({"user1","user2"})*/
              local!report: null,
              /*Populate the local!report with the Report document or document id of the Report*/
              local!desiredProcessModelIds: {},
              /*Populate the local!desiredProcessModelIds with the Process Model Ids or a constant that holds multiple values of type Process Model*/
              local!portalReportDataSubset: a!queryProcessAnalytics(
               report: local!report,
               contextUsers: local!contextUsers,
               query: a!query(
                        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1),
                        logicalExpression: a!queryLogicalExpression(
                         operator: "AND",
                         filters: {
                                  a!queryFilter(field: "c7", operator: "in", value: local!desiredProcessModelIds)
                                  /*Replace c7 with the field that represents Process Model Id*/
                         }
                        )
               )
              ),
              fn!if(
                        local!portalReportDataSubset.totalCount = 0,
                        null,
                        /*Remove duplicates*/
                        fn!union(fn!cast(fn!typeof(local!portalReportDataSubset.data),{}),local!portalReportDataSubset.data)
              )
    )


  • 0
    Certified Senior Developer
    Thanks sikhivahans,

    Have created the report as mentioned in your comment. Its working fine. Now the problem I am facing is : We have a requirement to filter the tasks which have not been accepted by any user. Am using following query filter for it -

    a!queryFilter(field:"c6",operator:"is null")
    where "c6" denotes the Owner of the task i.e tp!owner

    But this not working.
  • @vikrantb Apologies that I couldn't respond to your latest comment as the mail associated with my forum account was deactivated. I will take a look at it now and will let you know my findings if any.
  • The discussions on the question posted above, at last, are being made in a new post at forum.appian.com/.../e-217325.
  • When we use loggedinuser at contextUser:loggedinUser(), its throwing an error.

    [startIndex=0, batchSize=0, sort=, totalCount=0, data=, identifiers=, name=My Test Report, description=, columnConfigs=, errorMessage=Empty context passed in for report FICDSA FCC Tasks [id=188160]. (APNX-1-4156-000)]