Need help/suggestion in updating existing values in multiple dropdown

Hi , I have a multiple dropdown inside a grid layout , so choice values for that dropdown  previously static one coming from database , but now we have changed it as cascading one based on condition the dropdown choice value will change. Now the existing request are all throwing error. I thought of based on the request created date to change the choice values to be selected but i am not sure where that condition can applied inside the dropdown choice or before , because for new request also for choice values i have applied some if condition . Its not working properly. Can anyone help me to identify the option which is efficient?

a!localVariables(
  local!fundlookup: {
    a!map(lookupId: 1, value: "Comment A"),
    a!map(lookupId: 2, value: "Comment B"),
    a!map(lookupId: 3, value: "Comment C"),
    a!map(lookupId: 4, value: "Comment D"),
    a!map(lookupId: 5, value: "Comment E"),
    a!map(lookupId: 6, value: "Comment F"),
    a!map(lookupId: 7, value: "Comment G"),
    a!map(lookupId: 8, value: "Comment H")
  },

  local!Requestmaster: a!map(createdOn: todatetime("2025-09-10")),

  local!commonFund: if(
    local!Requestmaster.createdOn < todatetime("2025-09-18"),
    remove(local!fundlookup, { 7, 8 }),
    index(local!fundlookup, {1, 7}, {})
  ),

  local!mutualFund: if(
    local!Requestmaster.createdOn < todatetime("2025-09-17"),
    remove(local!fundlookup, { 7, 8 }),
    index(local!fundlookup, {1, 5}, {})
  ),

  local!citFund: index(local!fundlookup, {2, 3}, {}),

  local!productCommentIds: {},

  a!multipleDropdownField(
    label: "Select Comments",
    choiceLabels: if(
      ri!fundType = 100, /* Dummy CIT fund type ID */
      index(local!citFund, "value", {}),
      if(
        ri!fundType = 200, /* Dummy Mutual fund type ID */
        index(local!mutualFund, "value", {}),
        index(local!commonFund, "value", {})
      )
    ),
    choiceValues: if(
      ri!fundType = 100,
      index(local!citFund, "lookupId", {}),
      if(
        ri!fundType = 200,
        index(local!mutualFund, "lookupId", {}),
        index(local!commonFund, "lookupId", {})
      )
    ),
    placeholder: "---Select Comment---",
    value: local!productCommentIds,
    saveInto: local!productCommentIds
  )
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    If I'm understanding your use case correctly, based upon your description and your code:

    • You want the dropdown to have its choiceLabels / choiceValues change based upon the fund type
    • However, any existing data which breaks your intended data hierarchy will cause an error
      • i.e. for a given row in your grid, if the comment dropdown has a value that used to be valid but is no longer valid based upon the fund type, an error is thrown.

    If that's not the case, then please ignore this.

    If that IS the case - this is a pretty common type of request from the business, and also a pretty common problem to handle (in my experience). Stuff like invalidated values in a dropdown drives me crazy all of the time. On my wish list is for Appian to handle this by showing a null value and a validation error on the component rather than a pink box on the entire screen.  

    However, even that wouldn't solve a core problem you have - you'll need to figure out how you're going to update your existing data to the new hierarchy. Suggested routes:

    1. If you're in production and have data already, then someone will need to craft database scripts to fix the existing data, and then record sync after those are run.
      1. Any productCommentIds that don't match the corresponding fundType would need to be removed from your data, or updated to the correct values for the fund type
    2. Force the users to fix it on the UI
      1. Whenever the fundType changes, you'll need productCommentIds to remove the invalid values or (better yet) set productCommentIds to null.
      2. This is easier to do if the productCommentIds variable is accessible from the fund type dropdown. Since you mentioned that this is a grid, it's likely easy to do if they're on the same row. Experiment by adding something like this pseudo code to your fund type dropdown's save into: a!save(fv!item[productCommentIds], {}) , or however you reference product CommentId's from the grid.
    3. It is possible to create a generic UI component that handles an invalid value by showing a rich text field + error + removal link rather than a dropdown. You might think this is the right fix, but...
      1. It's a component I usually create when starting a new project, since it can prevent a lot of issues in early project development.
      2. Most business users find it confusing since there's no way to get the proper label for a value ("what is this id '32'???"). So really it's not the best method to handle a use case that's already in production. 
      3. Generic components like this can be finicky to understand and use properly when there are additional a!save() lines to manage
Reply
  • 0
    Certified Lead Developer

    If I'm understanding your use case correctly, based upon your description and your code:

    • You want the dropdown to have its choiceLabels / choiceValues change based upon the fund type
    • However, any existing data which breaks your intended data hierarchy will cause an error
      • i.e. for a given row in your grid, if the comment dropdown has a value that used to be valid but is no longer valid based upon the fund type, an error is thrown.

    If that's not the case, then please ignore this.

    If that IS the case - this is a pretty common type of request from the business, and also a pretty common problem to handle (in my experience). Stuff like invalidated values in a dropdown drives me crazy all of the time. On my wish list is for Appian to handle this by showing a null value and a validation error on the component rather than a pink box on the entire screen.  

    However, even that wouldn't solve a core problem you have - you'll need to figure out how you're going to update your existing data to the new hierarchy. Suggested routes:

    1. If you're in production and have data already, then someone will need to craft database scripts to fix the existing data, and then record sync after those are run.
      1. Any productCommentIds that don't match the corresponding fundType would need to be removed from your data, or updated to the correct values for the fund type
    2. Force the users to fix it on the UI
      1. Whenever the fundType changes, you'll need productCommentIds to remove the invalid values or (better yet) set productCommentIds to null.
      2. This is easier to do if the productCommentIds variable is accessible from the fund type dropdown. Since you mentioned that this is a grid, it's likely easy to do if they're on the same row. Experiment by adding something like this pseudo code to your fund type dropdown's save into: a!save(fv!item[productCommentIds], {}) , or however you reference product CommentId's from the grid.
    3. It is possible to create a generic UI component that handles an invalid value by showing a rich text field + error + removal link rather than a dropdown. You might think this is the right fix, but...
      1. It's a component I usually create when starting a new project, since it can prevent a lot of issues in early project development.
      2. Most business users find it confusing since there's no way to get the proper label for a value ("what is this id '32'???"). So really it's not the best method to handle a use case that's already in production. 
      3. Generic components like this can be finicky to understand and use properly when there are additional a!save() lines to manage
Children
No Data