User attempts to sort by the entity name field and does not behave as expected

I have a Tempo Task report that is showing tasks for a certain process. The Task Report has a column called Entity that corresponds to a Entity ID that is contained in a pv in the process. I am using a separate query to pull all of the relevant Entity CDTs and then using the displayvalue() function to display the Entity Name in the report instead of the Entity ID. So far so good.

If a user attempts to sort by the Entity Name field it does not behave as the user expects. Since the column is actually backed by the Entity ID in the PortalReportDataSubset, the report sorts in order of Entity ID instead of alphabetically by Entity Name (the value that is being displayed to the user).

Has anyone encountered any good work arounds?

OriginalPostID-137632

OriginalPostID-137632

  Discussion posts and replies are publicly visible

  • +1
    Certified Lead Developer
    Dan,
    I've encountered a similar issue in an entity backed grid with Appian data mixed in (like getting a last name from user() called on a username stored in a table).

    What you might do is make a dictionary with all of the data to show up in the grid. Say your portal report returns a list of entityIds and a list of otherFields.
    Then make a rule which builds a dictionary:
    rule!makeDictionary
    Inputs: ri!entity,ri!otherField
    Definition: ={fieldLabel: ri!entity, otherField: ri!otherField, ...}
    Now apply it over the merged lists:
    apply(rule!makeDictionary, merge(local!yourListOfEntitiesYouGotFromUsingDisplayValue, local!otherFields,...))
    The point is that now you can use "fieldLabel" as the 'field' in your GridTextColumn.

    This has a major limitation, though, in that it only really works well if you can get all of the data in your initial report or query, and only trim things down with todatasubset. Otherwise, you'll just be sorting a single page when you should be requerying to get the first results of the newly ordered data. In this case, I don't know of a good work-around.
  • Yes, your answer makes sense and is something I had considered, but our use case is such that paging is a must as there is no real guarantee on how many tasks a user may have.
  • Dan,

    A few things come to mind:

    1) If you have access to the text descriptions and a way to map them to your ID's without database interaction (maybe you control the updates to your entity table and you can cache this data in a constant), you could add a column to your portal task report that uses an expression to do the mapping there. I could see this causing some performance problems if your expression is too complicated or you have too many tasks.

    2) You could add a parallel text version of your process variable and use that in your portal task report. If you have long lived, already running process instances in production and its an important enough feature, you could look at a combination of process upgrade and Set External PVs to get those instances updated with the correct text values.