How do you get soft-deleted items as an option in a select?

How do you get soft-deleted items as an option in a select?

amsReedamsReed Posts: 1Questions: 1Answers: 0
edited October 2019 in Free community support

We soft-delete most of our data, but I have not been able to find a solution to a problem. Given the following data, how do you have the Editor show the location in a select of the field you are editing even though it may not be in the option list.

{
    "data": [
        {
            "DT_RowId": "row_1",
            "employees": {
                "name": "Jim Bob",
                "location_id": "1",
                ...
            },
            "locations": { "name": "Soft-Deleted Location #1" },
        },
        ...
    ],
    "options": {
        "employees.location_id": [
            { "value": "2", "label": "Active Location #2" },
            { "value": "3", "label": "Active Location #3" },
            { "value": "4", "label": "Active Location #4" }
        ],
        ...    
    }
}

The idea is that an item on the table we are looking at points to a lookup value that may have been soft-deleted, but we want to retain that value while we allow editing of another field. So, using the above data we want to update a "notes" field for "Jim Bob" without forcing it to update the "location_id" to one of the currently active locations. At the same time we want all new records to only have the active locations for options.

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    Use a database and soft delete the respective record. Afterwards ajax reload the data table.
    In the options instance to select from you can exclude the soft deleted options while still showing them elsewhere in the data table depending on the WHERE clauses you use. Since the options instance has its own WHERE clause this usually isn't a problem.

This discussion has been closed.