Querying data on the record summary view and passing it to a related action

I have a record with multiple related actions displayed as cards using the a!recordAction field on the record summary view. Currently, when the user clicks on a related action, all of the data for that related action is queried in local variables on page load.

Many of these related actions use the same queries, so if the user clicks on two different related actions, they need to wait for that query to execute each time. The queries can be quite slow, so I am trying to figure out a way to query more data up front before the user goes into a related action so that a) the page load is faster, and b) the same query does not have to be run for each related action.

I tried adding additional fields to the data type of my record, and querying for the additional data I need in the Single Record Source query to populate those fields.

Here is an example of what I tried.  This is a genericized version of the rule that I use on my record to query a single record (the rule is under the "Source" tab of a record, and is called the "Single Record Source" 

  local!originalData: rule!querySingleRecordData(id: ri!id),
  local!finalDataWithOtherQueries: 'type!{urn:com:appian:TEST}singleRecordDataType'(
    ID: index(local!originalData, "ID", null),
    NAME: index(local!originalData, "NAME", null),
    DATE: index(local!originalData, "DATE", null),
    QUERY_DATA_FOR_RELATED_ACTIONS_1: rule!queryDataForRelatedActions1(id: ri!id),
    QUERY_DATA_FOR_RELATED_ACTIONS_2: rule!queryDataForRelatedActions3(id: ri!id)

This does work, as it allows me to pass any data from the single record query to any related action.  However, when the user clicks a the related action, either through a a!recordAction() field or directly on the record summary view, then the Single Record Source query is run multiple times which makes the related action load time slower than if I just left the query in a local variable on page load. Aparently this is expected behavior according to Appian Support.

Any suggestions on how to run multiple queries and then pass the data to different related actions in a performant way would be greatly appreciated.  I am open to not using a related action, or to creative suggestions!

  Discussion posts and replies are publicly visible

  • The way you have originally set up your related actions is the better and preferred way so that your forms can always get up to date data. It seems like you're just trying to look for a workaround due to slow queries. It would be better to solve the problem of why your queries are slow. Also, if you use the Interface Designer performance tab you can verify if it's really the queries causing performance issues.

    Querying single rows from a database or multiple rows of reference data are really quick and they happen in parallel when using local variables. If you're finding these queries to be slow, that means you might be using a database view which has a lot of joins. To ensure querying is always fast, I recommend using our new sync'd records feature where data is always persisted to Appian explicitly for fast reporting. 

  • Hi Danny,

    Thank you for the ideas. Let me provide some context to explain why I am trying to load more data up front:

    1. To your first point, the data I need to query does not update very often, and when it does I already re query for it on button clicks in the related action UIs. The same data is also used across multiple related actions. So in this case it really does make sense to load the data before hand.  I did already check performance tab, and it is definitely the queries themselves that are taking a long time.

    2. In our case we are using Snowflake as the business database using the Snowflake connected system plugin.  Snowflake is not designed for fast queries, and so query times are unpredictable and often over 2-3 seconds, sometimes up to 20 seconds.  The connected system plugin itself also adds time to each query. Snowflake is also not owned by me, so making changes is not really reasonable.  
    Do you know of anything that could help here?