Though i don't understand you very well. I would suggest you use a different variable, not allowedValues. because it is used all over the system, and you might find that on the edit meta-data, it is been set to null or 0, which will obviously cause it to be empty.
Secondly, i think you need to call the same function you called when you search, because when you add and go to edit meta-data, you are going to another page, where i am not sure if you have the code that execute the logic to pull those documents.