I am using a!queryProcessAnalytics for showing 'User tasks report' in grid

Certified Lead Developer

Hi,
I am using a!queryProcessAnalytics for showing 'User tasks report' in grid. I followed all the steps given in SAIL Recipes(forum.appian.com/.../SAIL_Recipes.html .
The only thing which I added extra is, I am using 'contextProcessModels' attribute for process model context. but irrespective of what value I have for contextProcessModels attribute it always shows the same data in report.

below is my code snippet for queryProcessAnalytics

local!report: a!queryProcessAnalytics(
report: cons!UC_TASKS_FOR_USER_REPORT,
contextProcessModels: cons!SMS_ADD_STUDENT_PROCESS_MODEL,
query: a!query(
pagingInfo: local!pagingInfo
)
)
          
Thanks
Ajinkya

OriginalPostID-174579

  Discussion posts and replies are publicly visible

  • @ajinkya bhai Correct, to the best of my knowledge, the new addition i.e. contextProcessModels shouldn't make any difference. Because the report you have chosen, Task per User, has a context of its own, i.e. the report has the user as a context.

    So even if you make use of other arguments such as contextProcessModels, contextGroups they won't make any impact on your query and I guess that's an expected behavior because the report object constructed by you wouldn't be able to recognise any context other than User.

    Thumb rule is, you should be always passing the context to the report based on its category. Processes per Process Model expects process model(s) as context, Tasks per Group expects Group as context and so on.

    And re the solution, to work around this as per the experience I have so far is:
    1. Add a new column of type Number Integer in the report and configure its value as pm!id, you may call it as Process Model Id.
    2. And make use of the query filter in the queryProcessAnalytics as follows:

    a!queryProcessAnalytics(
    report: cons!UC_TASKS_FOR_USER_REPORT,
    query: a!query(
    pagingInfo: local!pagingInfo,
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(field: "c2", operator: "in", value: {cons!SMS_ADD_STUDENT_PROCESS_MODEL}),
    /*
    \ tLet's say 'c2' represents the new column of type integer configured in your report which holds the value pm!id
    \ tcons!SMS_ADD_STUDENT_PROCESS_MODEL auto boxes to integer and your report will be filtered\t
    \ t*/
    }
    )
    )
    )

    I hope that gives you leads over the issue. Still if you have any questions or issues or concerns feel free to reach out to me bhai. :)
  • Does this return the correct results? Or something else? It looks like your a!query() is incomplete.

    forum.appian.com/.../System_Functions.html
  • 0
    Certified Lead Developer
    @Tom: It ignores the context for process model id as Chose 'Tasks attribute to user' option while creating the report. so it only consider the 'contextUsers ' attribute.
    @Sikhi: Yeah correct i need to go with filter option as it ignores the other attribute.
  • @Tom Ryan I guess it's all about context in the queryProcessAnalytics(). If you take a quick look at the https://forum.appian.com/suite/help/7.11/System_Functions.html#a!queryProcessAnalytics.28.29, you can see that a query can just have pagingInfo and all the remaining arguments aren't necessary.

    Ideally when an Appian report object has context (such as Processes per Process Model has Process Model as context, Tasks Per Processes has Process as context), the same kind of context should be sent as an argument while invoking queryProcessAnalytics. Still we can pass an other context which is different from the context of report object, but queryProcessAnalytics doesn't throws any exception and safely skips it which thereby doesn't make any difference in the results we obtain.