How does contextProcessModels property of a!queryProcessAnalytics() function wor

How does contextProcessModels property of a!queryProcessAnalytics() function work?

My a!queryProcessAnalytics() function works great below when using contextProcessModels, but when I try and switch to contextProcessIds to display just the current process, it returns nothing. So then I backed up and just tried to hard-code the process ID that I want which is 6400, and that doesn't work. I tried using the processId variable and toInteger(6400) but no luck. What gives?

How is the contextProcessIds used correctly to return just those process IDs (pp!id) and can you show an example?

Thanks much!

local!report: a!queryProcessAnalytics(
report:cons!eOff_TASKS_GRID,
/* contextProcessModels: cons!EOB_MAIN_PROCESS_MODEL, */
           contextProcessIds:{tointeger(6400)}
          
           /*
contextProcessIds:
           contextProcessModels:cons!eOFF_MAIN_PROCESS_MODEL
           contextProcessIds:6400,
           ri!processId,*/
          
/*


OriginalPostID-201423

OriginalPostID-201423

  Discussion posts and replies are publicly visible

  • The Appian Doc on a!queryProcessAnalytics() is below and specifies: contextProcessIds (Integer Array): One or more process ids to pass to the report context.

    I can not get contextProcessIds to work at all. Does anyone know how this should work and/or has an example?

    Your help is greatly appreciated!

    a!queryProcessAnalytics()
    Executes the provided process report and returns the resulting data.

    Syntax

    a!queryProcessAnalytics(report, query, contextGroups, contextProcessIds, contextProcessModels, contextUsers)

    report (Document): .arf document containing the report configuration.
    query (Query): An optional query object containing paging and extra filters, created with a!query(). If no query is provided, the default paging from the report is used.
    contextGroups (Group Array): One or more groups to pass to the report context.
    contextProcessIds (Integer Array): One or more process ids to pass to the report context.
    contextProcessModels (Process Model Array): One or more process models to pass to the report context.
    contextUsers (User Array): One or more users to pass to the report context.
    Returns

    PortalReportDataSubset
  • @greggl Would you be able to let us know the category of Process Report?

    In order to use 'contextProcessIds' parameter, the report should have 'Process' as context. For instance, the Process Report 'Tasks by process' has context of 'Process'.

    Just in case, if your Process Report didn't have the Process as context, you may add a new column in it (let's say 'Process Id') and configure its value with pp!id. Then you may use the same in the a!queryFilter().
  • Thanks for rapid response! The function's report property is to to a Constant (report:cons!eOff_TASKS_GRID) which points to the Report Document under same name and its Report Context: is set to the main process model ("eOff Main Process Model"). So it seems it does have the context of Process does it not? See screenshot.

    I also did already a 'Process ID' column to the report and configured it's value to pp!id. Can you give me an example of using a!queryFilter() with it and a!queryProcessAnalytics()? But I don't understand why it's not working if the report context is a process model. If that worked wouldn't need the a!queryFilter() way.
  • @greggl Here are two ways of doing it:

    Ex 1:
    a!queryProcessAnalytics(
    report: cons!eOff_TASKS_GRID,
    contextProcessModels: cons!EOB_MAIN_PROCESS_MODEL,
    query: a!query(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1),
    logicalExpression: a!queryLogicalExpression(
    operator: "AND",
    filters: {
    a!queryFilter(field: "cx", operator: "in", value: tointeger(ri!processId))
    \ t/* Replace 'cx' with a value that holds process id in the Report, for instance: c2 */
    }
    )
    )
    )

    Ex 2:
    a!queryProcessAnalytics(
    report: cons!eOff_TASKS_GRID,
    contextProcessModels: cons!EOB_MAIN_PROCESS_MODEL,
    query: a!query(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1),
    filter: a!queryFilter(field: "cx", operator: "in", value: tointeger(ri!processId))
    \t/* Replace 'cx' with a value that holds process id in the Report, for instance: c2 */
    )
    )

    Please do let me know in case if you have any follow up questions.
  • As you can see in the attached, the report output is a set of tasks and has the pp!id as last column, and the report context is a process model; so not sure why contextProcessIds won't return anything when those process ids are used.

  • Thanks for examples! How can I determine which 'cx' column is the right one? I know you can output the report to a text field so I can see which CX # would be correct; do you have that syntax?

    Thanks
  • Here is the expalnation re why the usage of 'contextProcessIds' isn't making a difference:

    So, a context parameter(contextGroups/contextProcessIds/contextProcessModels/contextUsers) being passed to the a!queryProcessAnalytics() should match the category of the context of the Process Report.

    For instance, if the category of Process Report is 'Process Model' (as per the attached example), then you can only use 'contextProcessModels' but not contextGroups/contextProcessIds/contextUsers. Infact using any other categories won't work and makes no difference. Simply speaking, a!queryProcessAnalytics() can accept AT MOST only one context and that too, it should match the category of the context in the Process Report(which is Process Model as per the report).
  • At a high level what I could suggest as of now is as follows:

    1. Print the datasubset initially as follows without any filters:

    a!queryProcessAnalytics(
    report: cons!eOff_TASKS_GRID,
    contextProcessModels: cons!EOB_MAIN_PROCESS_MODEL,
    query: a!query(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1)
    )
    ).columnConfigs

    Then you may see similar to below:
    {
    {
    label: "Task",
    field: "c0",
    drilldownField: "dp0",
    configuredFormatting: "NORMAL_TEXT",
    configuredDrilldown: "PROCESS_DASHBOARD"
    },
    {
    label: "Process ID",
    field: "c7",
    drilldownField: "dp7",
    configuredFormatting: "NUMBER",
    configuredDrilldown: ""
    }
    }


    2. Identify the desired column name (Process ID in your case) in the 'label' and pick the associated 'field'. This is what I have said by quoting it as cx.

    3. Post identifying the 'field' attribute, build the queryFilter.

    a!queryProcessAnalytics(
    report: cons!eOff_TASKS_GRID,
    contextProcessModels: cons!EOB_MAIN_PROCESS_MODEL,
    query: a!query(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1),
    filter: a!queryFilter(field: "c7", operator: "in", value: tointeger(ri!processId))
    )
    )

    Further I would like to suggest you going through forum.appian.com/.../Task_Report_Tutorial.html and forum.appian.com/.../System_Functions.html to gain insights over the functionality of a!queryProcessAnalytics().