I am trying to allow users to add custom text to a list in an app, but i cannot figure out how to get the list defined initially, and how to get the user input to add to the list.. this is what I have been trying:
input "customCommand", "text", title: "Enter a name for this custom command", required:false, submitOnChange:true
if(customCommand){
if(!customCommands){
def customCommands = []
}
customCommands << "${customCommand}"
log.debug customCommands
// reset customCommand for another input if needed
customCommand = null
}
customCommands.each{
input "RemoveCustomCommand", "button", title: "Remove ${it}"
}
ideally, this would end up with a list: customCommands = ["someCommand","command2","command3"]
the buttons would just display each command that the user setup, and when pressed would go to a function to execute customCommands.remove(customCommand)
the issue is I keep getting errors about customCommands being null and cannot add items to it.. similar to this error:
java.lang.NullPointerException: Cannot invoke method leftShift() on null object
Ive tried a handful of ways to get this to work, and was wondering if someone had any insight on if this is possible, and hopefully a better way to lay this out in an app preference config section.