Multiple dropdown

Hi Everyone,

I am displaying data in multiple dropdown using recordtype. I have the requirement to make the deselected values as inactive in db. Can anyone please guide me?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    I would achieve this by comparing the newly selected values with the previously stored values in the database.

    Steps:

    1. Fetch existing active values from the database when the form loads.
      (Use a!queryEntity() to retrieve records where status="Active" and store them in a local variable for comparison.)
    2. On selection change, compare the new selection with the previous selection.
      (Use difference() to find deselected values and intersection() to detect reactivated values.)

    e.g.   

    local!deselected: difference(local!activeSelections, local!newSelections),
    local!reactivated: intersection(local!inactiveSelections, local!newSelections)
    

    1. Identify deselected values and update their status to "Inactive".
      (Iterate over local!deselected for example and map each record’s status to "Inactive".)
    1. Use a!writeToDataStoreEntity() to update the database when the form is submitted.
      (Write the modified records back to the database, updating status accordingly.)

    2. For reactivation, check if a previously inactive value is reselected and update its status to "Active".

    I believe this would ensure deselected values become inactive and reselected values become active dynamically.

Reply
  • 0
    Certified Associate Developer

    I would achieve this by comparing the newly selected values with the previously stored values in the database.

    Steps:

    1. Fetch existing active values from the database when the form loads.
      (Use a!queryEntity() to retrieve records where status="Active" and store them in a local variable for comparison.)
    2. On selection change, compare the new selection with the previous selection.
      (Use difference() to find deselected values and intersection() to detect reactivated values.)

    e.g.   

    local!deselected: difference(local!activeSelections, local!newSelections),
    local!reactivated: intersection(local!inactiveSelections, local!newSelections)
    

    1. Identify deselected values and update their status to "Inactive".
      (Iterate over local!deselected for example and map each record’s status to "Inactive".)
    1. Use a!writeToDataStoreEntity() to update the database when the form is submitted.
      (Write the modified records back to the database, updating status accordingly.)

    2. For reactivation, check if a previously inactive value is reselected and update its status to "Active".

    I believe this would ensure deselected values become inactive and reselected values become active dynamically.

Children
No Data