Accessing Values in Dictionary

Certified Associate Developer

 

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

Id (PK), PartNumber, Status, Country_1, Country_2, Country_3, ..., Country_150

We are using CDT to get data from DB so output of CDT in dictionary format.

Expected output:
countries: {
{country_1, country_2, country_3, ..., country_150}----for 1 st row
{country_1, country_2, country_3, ..., country_150}-----for 2nd row
}
*** One way i found is writing index on all 150 columns  but it will increase code length  is ther other alternative way other than this

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Associate Developer
    in reply to 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?

  • 0
    Certified Lead Developer
    in reply to Goddati Venkatesh

    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.