13
Views
2
Comments
Solved
How to auto populate a list with similar list from a previous record, but editable?
Application Type
Reactive
Service Studio Version
11.8.9 (Build 30790)

I want to simplify the process of making new orders in my application. Here's the thing, my customers usually order the same things for their orders, just different amount sometimes. For example, for simplification, they usually orders 5 kg of flour, 5 kg of sugar, and 5 kg of butter.  Once in a while, though, they would change the amount, or add some other stuff. I want to speed up my order creation. Is it possible, when I make a new order for that customer, a certain list is already filled in. I should be able to edit them, though, before saving the new order. Why would I want to speed up this process? because usually the real list is around 20 items long, and they can order 8 times in a day.

I am still new in outsystems, so maybe that's a stupid question, I don't know. Please be kind to me.     :D

mvp_badge
MVP
Rank: #18
Solution

Hello Takada,

Welcome to OutSystems, your question is not stupid (are there stupid questions?).

You could consider an extra boolean attribute in your order entity called IsTemplate.

Any order with this attribute set to True is considered not an order that you deliver to a customer, but as a template that can be used to create an order from.

To allow a user to create template orders:

  • On your OrderDetails screen add a switch or checkbox to toggle the value of IsTemplate attribute.
  • Maybe you want to add some business rules to avoid that this action can be done if an order is already being or been processed.

To allow a user to select a template order and copy it to an order:

  • add the IsTemplate attribute with datatype Boolean to your Order entity. This will automatically set the default value to true, which is perfect so that any existing orders are not automatically considered to be a template. 
  • You probably have a screen where you lists al existing orders on this screen:
    • Add a button group with two buttons: Orders, Templates.
    • Filter the list of orders based on the button selected in the button group.
    • add a column to your table and place a link or button in it, give it a label like "Copy to order", and link it to a new screen action that you could name CopyTemplateToOrder, the action should have OrderId as input parameter.
  • In the new CopyTemplateToOrder screen action you
    1. Add an aggregate to select the template order by the Input OrderId.
    2. Create a new order by using the retrieved order and set the Id to NullIdentifier() and IsTemplate=False.
    3. Then add an aggregate to read all order lines by the InputOrderId
    4. Use a ForEach to read thru each order line set the Id to NullIdentifier and the OrderId foreign key to the Id returned in step 2
    5. No add a destination node to go to the OrderDetail screen and pass in the OrderId from step 2.

Maybe I missed something, but this should get you started.

Good luck with it.

Regards,

Daniel

Rank: #35473

Hi Daniel,

First of all, thank you very much for taking the time to help me. I really appreciate it.

Reading your suggestion, I believe that's a really good way to do what I want to do. I also think that's not too hard to build  (I hope)  :D

I'll try them soon. Thanks a lot for your help.  :)