Hi all,
I want to get fields in a CDT based on their numerical index, i.e. if I have a CDT like:
{'type!{urn:com:appian:types:TEST}TEST_Employee'('firstName': "Frank", 'secondName': "Smith", 'age': 29)}
To get the first field, is there a way to index it by number? Something like index(local!testCdt, 1, null) would return "Frank".
Thanks for your help!
Discussion posts and replies are publicly visible
Is there a specific reason to do that? While the order is typically fix, I would definitely not rely on it.
We have a list of attribute sections that a user can click through, and I need to keep track of which sections have been opened for editing. I've created a CDT that contains the list of attribute sections as the keys and booleans as the values, but I can't make the field names match the attribute section names exactly (one of them has a special character) and I can't make the field names the attribute index because Appian doesn't allow numerical values as field names.
What I was planning to do was to get the attribute section index, and use that to index the CDT to fetch the corresponding value.
So for example:
Attribute sections indexes and names that a user sees:
1. Name
2. Age & Address
3. Occupation
CDT structure:
'type!{urn:com:appian:types:TEST}TEST_isSectionOpenForEditing'(name: 1,ageAndAddress: 0,
occupation: 1 )
If the user clicks the second attribute section, Age & Address, I want to fetch the corresponding value from the CDT to verify whether that section is open for editing.
Let me know if that makes sense.
Why not store this in a key-value fashion? Then you can store the section technical names in constants and easily refer to them in UI and in the key-value store.
How would I keep this persisted in a key-value fashion? That's why I created the CDT, so I could have it in a key-value fashion and persist the data as a process variable in the relevant process model.
Hm ... do you need to persist this data to DB? If not, why even using a CDT where a map would do it?
You could go with
{ a!map(section: "NAME", open: true), a!map(section: "AGE", open: false), . . . }
To find the value, use displayvalue like this
displayvalue(cons!SECTION_NAME, local!status.name, local!status.open, false)
We might end up persisting it in the DB, but for now I was just using the CDT for the key value structure and so the data can be persisted as a process variable.
I guess if I take your approach I can store it as type "Map" in the process model, right?
If you plan to persist this, go with a CDT and add a primary key field.
But you can also store the list of maps in a PV and transform it into CDT later on.
johng0005 said:How would I keep this persisted in a key-value fashion?
You can do pretty much whatever you want if you use an expression rule, FWIW
The beauty of that is, you can design an expression rule using a "black box" approach, such that you can start out with hardcoded or even "faked" values, and if/when you decide to shift to a DB-backed approach, you can simply update that expression rule to do whatever internal querying it needs to do, in order to return the same values based on the input passed in.