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
  • 0
    Certified Lead Developer

    Hi   I am aware you have a solution now yet I feel I couldn’t understand your usecase properly the other day and suggested to alter your existing view as solution. Though now I think a view is not needed  /appropriate for your use case at all.

    Instead of a view you can query country column from the child table by request id within Appian expression rule so that the output you receive (the country names) will be a list of strings. In your main rule where you are creating this dictionary with the countries, you can use the function joinarray() with separator as comma(,) like below.

    joinarray(local!listOfCountries,”,”) 

    Here you need to replace the variable to variable that contains list of countries for given request id after querying data/ the expression rule that returns countries from child table. 

    This doesn’t require a view and using a!foreach() you can get the expected output for each request id. 

Reply
  • 0
    Certified Lead Developer

    Hi   I am aware you have a solution now yet I feel I couldn’t understand your usecase properly the other day and suggested to alter your existing view as solution. Though now I think a view is not needed  /appropriate for your use case at all.

    Instead of a view you can query country column from the child table by request id within Appian expression rule so that the output you receive (the country names) will be a list of strings. In your main rule where you are creating this dictionary with the countries, you can use the function joinarray() with separator as comma(,) like below.

    joinarray(local!listOfCountries,”,”) 

    Here you need to replace the variable to variable that contains list of countries for given request id after querying data/ the expression rule that returns countries from child table. 

    This doesn’t require a view and using a!foreach() you can get the expected output for each request id. 

Children
No Data