Getting cdt data from a dse

Certified Senior Developer

I have an expression that takes in a dse and spits out the column names of everything in that dse. Unfortunately, the way it does this is by querying the dse and then running a!keys() on the first entry of the result to figure that all out. While this works perfectly well when the dse has values in it, it will error out if the table is empty. So is there any way to get the same information directly from a DSE that doesn't have data in it? 

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to Chris

    I just whipped up this quick expression rule which, storing a list of data store entities and their accompanying CDTs, one can pass a DSE (like via constant) and it'll find the matching item in the list.  If I were implementing this for real I'd probably store the list of maps in "local!pairs" in its own expression rule (for universality) and just reference it from this one.

    a!localVariables(
      local!pairs: {
        a!map(
          entity: cons!APP_ENTITY_PERSON,
          type: 'type!{urn:com:appian:types:APP}APP_Person',
          typeId: tointeger('type!{urn:com:appian:types:APP}APP_Person'),
          keys: a!keys('type!{urn:com:appian:types:APP}APP_Person'())
        ),
        a!map(
          entity: cons!APP_ENTITY_EQIP_SUBMISSION,
          type: 'type!{urn:com:appian:types:APP}APP_eQIPSubmission',
          typeId: tointeger('type!{urn:com:appian:types:APP}APP_eQIPSubmission'),
          keys: a!keys('type!{urn:com:appian:types:APP}APP_eQIPSubmission'())
        )
      },
      
      local!index: where(local!pairs.entity = ri!dse),
      
      index(local!pairs, local!index, null())
    )

    As seen here, we can even have it directly provide us the CDT "keys" array as a member of the output set(!)

  • Nice!  We are not on a version that supports a!keys() yet :(.  I believe that was introduced in 21.4?

  • 0
    Certified Lead Developer
    in reply to Chris

    Yeah, plus or minus a version.  AFAIK there might be a usable workaround if you need, like by populating an empty member of the data type then scraping the text for the property names.