Updating/edting multiple records from multiple entities 

Updating/edting multiple records from multiple entities 

  

Has anyone built a solution or worked with an extension that allows for edting multiple records from multiple entities on a single page? If so, can you point me to the proper resource for doing this? Thanks.

Hi Clayton, and welcome to the OutSystems community!

Indeed, it is common for such things to be done, and they can be done the same way you edit a single entity.

Depending on the scenario, the way to do it would be the following:

1 - In the preparation action, you should retrieve all the records you want to edit - either using a single or many queries to the database;
2 - In the screen, you should present the information you want to be edited, in a single or many Edit Record widgets;
3 - In the "Save" action of the screen, you then must use the create or update actions for each of the individual records you want to store, depending on the entity they belong to.

For instance - and I'm just guessing, mind you, but - the "Submit a post" screen of these forums edit a POST entity record, with the title and text you want to insert (plus adding your own user id, and associating the post to a specific TOPIC entity), and when you attach a file, it'll probably be stored in another entity, suppose an ATTACHMENT entity.

Does this answer your question somehow?

If not, please let us know in more detail what your question is - and I would also recommend taking a look at the "Getting Started" and "OutSystems Fundamentals" topics in our Academy.

Regards,

Paulo Tavares
Paulo;

Thanks for getting back to me your feed back at least tells me I'm headed in the right direction but there are still issues in the flow I don't know how to render.

For instance, I have a contacts entity and a subscriptions entity. The entities are related by a PK/FK. I have two queries. One that fetches the contact's data and one that fetches the contact's n subscription preferences. When I render an edit screen for a contact, I want to display the contact data for editing as well as all of that contact's subscription preferences for editing.

What I can't figure out is how to iterate over the subscriptions record list returned by my query and dynamically create the n edit record widgets along with the contact data.

Does this make any sense and do you have any further suggestions?

Thanks,

Clay
Hi Clayton,

Sorry for the late reply.

I'm not sure if I got your requirements correctly, but let me try to answer you.

Scenario 1: a page to edit one customer's data, and one subscription

Preparation:

- One query, that fetches both the customer and the subscription, associating the subscription to the customer through the PK/FK relationship;

Screen:

- One Edit Record, for the customer's data, and a separate one (or you could re-use the same) for the subscription data.
- A Save button

Save Action:

- An Update Customer record action, and an Update Subscription action.

Scenario 2: a page to edit one customer's data, and many subscriptions

Preparation:

- One query, that fetches the customer, and a second query that retrieves all the user's subscriptions, by crossing them with the PK/FK relationship;

Screen:

- One Edit Record, for the customer's data;
- A Table Records, that receives the subscriptions query's result set as input. You should change the table record, so that instead of expressions you would have Text Inputs displaying the data to be edited.
- A Save button

Save Action:

- An Update Customer record action,
- A for each loop that iterates through the table record's list, and an Update Subscription action for each record.

Note that this second scenario might not be the best one for scale purposes (i.e. iterating 20 subscriptions and storing 20 at a time, even if possibly none has been changed) or if the subscription data is too much. If that's the case, you may either have:

- a table records to display all the subscriptions, as usual, and then in each line you would have a link to an Edit Subscription page. No Text Inputs in the table records;
- Ajax actions to store the edited subscriptions.

I hope that this textual explanation has somehow helped you understand what I was trying to explain.

Do not hesitate to let us know if you have further questions!

Good work.

Paulo Tavares
Paulo;

Thanks for the feedback. Scenario 2 is just what I needed to keep moving forward.

However, I've hit another roadblock. My issue is similar but different that the last issue. I have used a table records list to list a set of survey responses for a given contact. The answer values to each of those questions is either "Y", "N" or null. I have two radio buttons as the input widgets to capture/display the answer value. 

My problem is neither button is appearing checked when I display the record even though the query is returning data (either "Y" or "N").

Any feedback or advice would be appreciated.

Thanks, 

Clay
Hi Clayton,

Sorry for the late reply, yesterday was a national holiday here.

I would say that, for the case you're handling, you should do the following in the Radio Button's properties:



Hopefully this will sort out the behavior you're expecting. If not, it's probable that I'm forgetting something here...

Let us know if this helps!

Regards,

Paulo Tavares