26
Views
4
Comments
Automatically remove empty fields if they are not filled in
Question

Hi!

I have a problem with my pop up. 

I have a list and below it a button that adds inputs and saves them in that list.

The problem is that when I press the '+' button to add another field. If I don't fill it with anything, it stays saved as an empty input. And what I would like to do is if I press the add button, I don't fill the input and leave it blank, so that I don't save that empty element when I close the popup. 

By the way, the fields are automatically saved when you click on a person in the list. And the Save button just closes the pop up, as those changes are already saved automatically.

I hope I have explained myself well

Thank you very much!

After clicking on save or on the close button go through the list and remove what is empty... But why are you saving everything automatically, shouldn't you just save if you click on the save button? :D

That would be easier... Once you click you just need to filter the list and make sure you filter to get the records which have both inputs/attributes filled and then save. You can do this with he list itself which is being consumed on the screen and then on a for each you check if both inputs are filled and if they are you save.

Kind Regards,

Márcio

Hi @Mario Sepulveda ,

Follow the below steps :

1)In save on click drag and drop a for each and iterate the list.

2)In the iteration check that those two fields are empty or not

3)If it is empty remove the record.

4)Now use the not empty list for create/update


I hope this will work!

Thanks & Regards,

Sudip Pal

Hello @Mario Sepulveda ,


If I understand correctly you do not want to save the empty records in the list but it is happening right now?

I assume the save is a loop that walks through the list of attendees and saves them?

If that is the case I think the easiest thing you can do is adjust the logic of the save action with an extra if-statement that checks if the current value is empty and if so skip the save/crud action and continue the loop.

Please let us know if this helps.


Edit: Just read the comment of @Márcio Carvalho and this would indeed be the better solution.

Hello  Mario Sepulveda,

 Agree with Marcio, instead of saving the data on selecting the name, you should use the save button and immediate back from the pop up,

but in you current logic add if condition in your OnChange action to check the value of drop down whether it is empty or not (if you are using entity attribute as drop down value  then If condition wont work, you need to use local variable (of entity's identifier, the one you are using as a list in drop down ) as drop down value ). If  Empty then close pop up or provide feedback message or if it has value then save it to database and close the popup.

Hope this helps,

Komal


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.