How to improve this functionality to reduce repetition

I have a UserDetail screen with a form with some user fields (name,etc). But in this screen I want to have the functionality to add and update adresses for this specific user. I want to show each added address of the user in a tablerecords and then in the table records should appear a button "Update" next to each address to show a popup to update that clicked address. 

Its working, however there is an issue that Im not understanding why when the "Add Address" button is clicked, the address field is always populated with the third address of the user, but this address field should be empty ("") in the popup. Do you know why is not empty? 

And also do you know if there is a better approach for this functionality? Because for this functionality I have two screeens, the AddAdress scren to show the popup to add new adresses and the UpdateAdress screen to show a popup to update an address. And also in each screen, AddAdress and UpdateAdress, I have the specific input parameter (CustomerId for the AddAdress screen and AdressId for the UpdateAdress screen), a preparation, and the screen action "Add" in the AddAdress screen and the action "Update" in the UpdateAdress screen. And also in the UserDetail screen I have two OnNotify, the OnNotify for the AddAdress screen and the OnNotify2 for the UpdateAdress screen. 

Context flow: 

To add a new address:

 - In the UserDetail screen, I have a button "Add Adress" when this button is clicked it shows the popup "AddAdress" 

- The AddAddress screen has a preparation to get the addresses where "UserId = Adresses.UserId", UserId is an input parameter to the AddAdress screen

 - The AddAdress screen has a form with Source Record "GetAdressesByUserId.List.Current" and the form has only one field "Address" with the variable "AdressesForm.Record.Adresses.Address"

 - The AddAddress screen has an action "Add" with an assign "AdressesForm.Record.Adresses.UserId = UserId" and with a CreateAdresses entity action, the source of this entity action is "AdressesForm.Record", then there is a Popup_Editor_Close() and a Popup_Editor_Notify(), in the OnNotify of the UserDetail screen, the aggregate is refreshed and the adresses table is updated using ajax. It works, the issue is only that the address input field should be empty in the popup and its not.

 To update a new address: 

- In the UserDetail screen addresses table records, I have a button "Update" when this button is clicked it shows the popup "UpdateAdress" 

- The UpdateAdress screen has a preparation to get the addresses where "Adresses.Id = AdressId", AdressId is an input parameter to the UpdateAdress screen

 - The UpdateAdress screen has a form with Source Record "GetAdressById.List.Current" and the form has only one field "Address" with the variable "AdressesForm.Record.Adresses.Address"

 - The UpdateAdress screen has an action "Update" that has a UpdateAdress entity action, the source of this entity action is "AdressesForm.Record", then there is a Popup_Editor_Close() and a Popup_Editor_Notify(), in the OnNotify2 of the UserDetail screen, the aggregate is refreshed and the adresses table is updated using ajax. It also works.

OsCaR_ wrote:

I have a UserDetail screen with a form with some user fields (name,etc). But in this screen I want to have the functionality to add and update adresses for this specific user. I want to show each added address of the user in a tablerecords and then in the table records should appear a button "Update" next to each address to show a popup to update that clicked address. 

Its working, however there is an issue that Im not understanding why when the "Add Address" button is clicked, the address field is always populated with the third address of the user, but this address field should be empty ("") in the popup. Do you know why is not empty? 

And also do you know if there is a better approach for this functionality? Because for this functionality I have two screeens, the AddAdress scren to show the popup to add new adresses and the UpdateAdress screen to show a popup to update an address. And also in each screen, AddAdress and UpdateAdress, I have the specific input parameter (CustomerId for the AddAdress screen and AdressId for the UpdateAdress screen), a preparation, and the screen action "Add" in the AddAdress screen and the action "Update" in the UpdateAdress screen. And also in the UserDetail screen I have two OnNotify, the OnNotify for the AddAdress screen and the OnNotify2 for the UpdateAdress screen. 

Context flow: 

To add a new address:

 - In the UserDetail screen, I have a button "Add Adress" when this button is clicked it shows the popup "AddAdress" 

- The AddAddress screen has a preparation to get the addresses where "UserId = Adresses.UserId", UserId is an input parameter to the AddAdress screen

 - The AddAdress screen has a form with Source Record "GetAdressesByUserId.List.Current" and the form has only one field "Address" with the variable "AdressesForm.Record.Adresses.Address"

 - The AddAddress screen has an action "Add" with an assign "AdressesForm.Record.Adresses.UserId = UserId" and with a CreateAdresses entity action, the source of this entity action is "AdressesForm.Record", then there is a Popup_Editor_Close() and a Popup_Editor_Notify(), in the OnNotify of the UserDetail screen, the aggregate is refreshed and the adresses table is updated using ajax. It works, the issue is only that the address input field should be empty in the popup and its not.

 To update a new address: 

- In the UserDetail screen addresses table records, I have a button "Update" when this button is clicked it shows the popup "UpdateAdress" 

- The UpdateAdress screen has a preparation to get the addresses where "Adresses.Id = AdressId", AdressId is an input parameter to the UpdateAdress screen

 - The UpdateAdress screen has a form with Source Record "GetAdressById.List.Current" and the form has only one field "Address" with the variable "AdressesForm.Record.Adresses.Address"

 - The UpdateAdress screen has an action "Update" that has a UpdateAdress entity action, the source of this entity action is "AdressesForm.Record", then there is a Popup_Editor_Close() and a Popup_Editor_Notify(), in the OnNotify2 of the UserDetail screen, the aggregate is refreshed and the adresses table is updated using ajax. It also works.


From what I understand the issue is due to your preparation in AddAddress where you're fetching Address for the User Id and I guess there are already addresses saved against that UserId. Since when you're adding an address you don't have to use an aggregate in the preparation. You can just have an Address local variable and pass it to the entity action on Add.

Hi OsCaR_ ,

A very neat & specific question.. Appreciate Personally.

Perhaps would be more helpful if you add Screenshots of Screens & Popup & Issue to the Question.

- Assif

Hello  OsCaR_,

In order to reduce the number of screen, you can implement a modal component, you can check how here

https://success.outsystems.com/Documentation/11/Developing_an_Application/Design_UI/Patterns/Using_Web_Patterns/Content/Modal

the behavior is similar to the popup but the modal is an actual element of the page. 


Regarding the issue of the populated fields, my best guess is that you may be setting the inputs of the popup with the values of the query instead of the table records.

Best Regards

Hi OsCaR_,

address field should be empty ("") in the popup. Do you know why is not empty?

What is the source record variable ? are you using that variable any where for assignment ?

I'm sure giving solution in this way is very difficult, provide screenshot where your facing issues or share oml file to get it addressed.


Sravan

 

Thanks, the scenario is like this:


It's working with only 1 screen, for that, I have UpdateAdresses screen that has:

- an input parameter AddressId

- an input parameter CustomerId

- a preparation to get the addresses with a filter "Adresses.Id = IntegerToIdentifier(AddressId)"

- an Update action that has:

        - an assign "AdressesForm.Record.Adresses.UserId = IntegerToIdentifier(UserId)"

        - a CreateOrUpdate action with the Source "AdressesForm.Record"

        - a popup editor close

        - a popup editor notify  

Then in the UserDetail screen, there is the OnNotify that refreshes the table record.

 

Do you know if this is a correct approach? 


And also do you know why it work with the filter "Adresses.Id = IntegerToIdentifier(AddressId)" but not with the filter "Adresses.UserId = IntegerToIdentifier(UserId)"? With "Adresses.UserId = IntegerToIdentifier(UserId)" in the UpdateAdresses screen preparation don't works properly? With this filter when the user clicks in "Add Address" the address field in the popup doesn't appear empty, instead appears populated with an existing address and also when the user clicks on the button "Save" in the popup the address is not added to the table records. Also when the user clicks in the Update button in any row it appears always in the popup the address field populated always with the same address and the address that is updated when the "Save" button in the popup is clicked is always the same address?

OsCaR_ wrote:

And also do you know why it work with the filter "Adresses.Id = IntegerToIdentifier(AddressId)" but not with the filter "Adresses.UserId = IntegerToIdentifier(UserId)"? With "Adresses.UserId = IntegerToIdentifier(UserId)" in the UpdateAdresses screen preparation don't works properly? With this filter when the user clicks in "Add Address" the address field in the popup doesn't appear empty, instead appears populated with an existing address and also when the user clicks on the button "Save" in the popup the address is not added to the table records. Also when the user clicks in the Update button in any row it appears always in the popup the address field populated always with the same address and the address that is updated when the "Save" button in the popup is clicked is always the same address?

If you are filtering only by UserId, then the query will always return the first address for that user and since you are using CreateOrUpdate_Address, the first address will always be updated. The correct pattern is filtering by AddressId.

The approach in your schematic looks technically correct, but opening a popup to create an address when you click to save the user record is a strange usability pattern. By your previous description it sounded like your button you say "Add address" and if that's the case, everything look right.