Skip to main content
January 13, 2022
Solved

How to display data Dropdown from rule using database

  • January 13, 2022
  • 8 replies
  • 0 views

Hi everyone i am new at Appian and i m trying  to understand how i display the labels and the choice values that comes from a DB . into a dropdown and save it in a rule input after

its throwing an error that i dont understand.

can someone explain what is my error and what is the better solution for doing this ? 

thank your

    Best answer by peter.lewis

    This is a tricky issue to troubleshoot - I believe what's happening is that there is a type mismatch between your choiceValues and your saved value. The choiceValues are of type dictionary (because that is what is returned by a!queryEntity()), but the value is of type Sector_Activity. For a dropdown field to work, the types and values must exactly match.

    It actually looks to met that you're pretty close with yoru commented out code - if you run the cast you already have there against your query result, it should cast correctly and it should eliminate the type mismatch.

    8 replies

    January 13, 2022

     and this is how i call the rule expressinon in my localvaraible

    stefanhelzle0001
    Brainy
    January 13, 2022

    The value AND data type of the parameters value and choicevalues must match. I assume that you want to store the ID of the selected sector and customer.Sector_Activity is an integer. Then 

    choiceValues: local!query_data_activity_sector.ID

    should work.

    BTW, your variable naming seems to not match the Appian best practices,

    docs.appian.com/.../Standard_Object_Names.html

    January 13, 2022

     i forgot to specify that customer is CDT and sector activity is also a CDT and i want to save all the values in the Sector_activity . When i m doing what you said it is throwing an error about the casting . how we doing the cast ? and for what reason i need to cast it ? 

    peter.lewis
    Employee
    January 13, 2022

    This is a tricky issue to troubleshoot - I believe what's happening is that there is a type mismatch between your choiceValues and your saved value. The choiceValues are of type dictionary (because that is what is returned by a!queryEntity()), but the value is of type Sector_Activity. For a dropdown field to work, the types and values must exactly match.

    It actually looks to met that you're pretty close with yoru commented out code - if you run the cast you already have there against your query result, it should cast correctly and it should eliminate the type mismatch.

    January 13, 2022

    i solved the problem , now it is working

    i had to do cast my result from the query entity (because it s returning a dictionary of CDT ) as you say , so i did a casting to a  list of my CDT.

    like in the picture , now i can display the content and save it in the rule input.