Appian Community and Appian Academy are being upgraded. From July 24–August 3, the Appian Community will be in read-only mode. During this time, the site will be read-only and user registration will be disabled. We apologize for any inconvenience this may cause, but a more secure, stable, and performant Community experience is coming soon!
The new Appian Community launches August 3, followed by Appian Academy on August 7. During the migration, Appian Community Edition, Appian Academy, Documentation, Certifications, Instructor-led Customer Training, Partner Sales Training & Accreditation, and Forum (for Appian Partners and Customers only) will remain available.
Hi team
I want to access values in a dictionary without using a loop, because in real-time we have 440 rows, and each row has 150 columns. Running a loop over each row to get values is causing performance issues.
I checked the Appian Community and found that we can use the a!keys() function to extract all keys
a!keys()
Id (PK), PartNumber, Status, Country_1, Country_2, Country_3, ..., Country_150We are using CDT to get data from DB so output of CDT in dictionary format.Expected output:
Id (PK), PartNumber, Status, Country_1, Country_2, Country_3, ..., Country_150We are using CDT to get data from DB so output of CDT in dictionary format.
Discussion posts and replies are publicly visible
Trying to manage 440 rows with 150 columns in memory does not feel like a good design decision.
What do you try to achieve?
Stefan Helzle The table has a maximum of 150 entries for each ID. For example, for request ID 1, we have 120 eligible countries, so there are 120 rows in the child table. For request ID 2, there are 50 eligible countries, so we have 50 rows in the child table.
In the main table, if I have 440 rows, then in the child table I will have up to 440 × 150 rows. To avoid this many loops, I created a view with the format mentioned above — where each request ID has all countries as columns. This way, I only need to run 440 loops to get the request ID and all country values into one variable.
From that variable, I want to extract only the country values, not other values like the request ID.
If you join the tables using request id then you will have multiple rows for each id in the view instead of columns! Querying which you can get all 120 countries as a list in Appian and wont need any loop. Did you try this way?
Harsha Sharma If I get multiple rows for each request, then I need to run a loop on the main data and a nested loop on the child data, right? Or is my understanding incorrect?
Say you create a view which has fields requestId and country. So when you query the view using request Id you will get the rows containing countries for that request. You will be able to access the country using dot(.) notation. For example, if you get the output of query in local!data variable, any of the below expressions can help access the country data. (Use variable/column name as in your data structure)
local!data.country or index(local!data,"country",{}) or property(local!data,"country",{})
While dot allows access column data simply, index() and property() helps in case you have a request which might have null or no country data and you will need to perform null checks.
You won't need for each to access the child data. If you want to manipulate or format them further then you might need a!foreach but that depends on usecase to usecase! Hope this helps.
OK, and then? What is the purpose of this?