Dynamically changing input fields in SmartApp

I’m would like to change the inputs fields displayed to the user in a SmartApp based on what previous selections he has made.

E.g. When the user Selects “Add” in the first input enum options field, I want a new input field to show up below asking for “UserId”. But when the user Select “Delete” instead of “add” from the enum options in the first input, I want the second input NOT to appear.

How can one achieve this?

@tslagle13 @Dave @minollo - looping you guys in for some inputs if you have suggetsions

Can you share the code you’re working on? I’d like to see what you are talking about. I think we can do a if statement there and have it refresh on selection but i’d need to see it to see what you want to do.

Sure, see below, I want the new user code option to pop up only if the use selects add:

preferences {
    section("Select Lock") {
        input "lock","capability.lock", title: "Lock"
    }
    section("User Management") {
        input "delete", "enum", title: "Add/Update/Delete User?", required: true, metadata: [values: ["Add/Update","Delete"]]
        input "user", "number", title: "User Slot Number", description: "This is the user slot number on the lock and not the user passcode"
    }

    section("Add/Update User Code") {
        input "code", "text", title: "User Passcode (check your lock passcode length)", defaultValue: "X", description: "The user passcode for adding/updating a new user (enter X for deleting user)"
    }
}

How about using dynamic pages?

yes but how I can’t seem to figure it out.