On Mon, Oct 21, 2019 at 4:17 PM Kirk Brooks via 4D_Tech < [email protected]> wrote:
> > A couple of thoughts. It sounds like you have a situation where you have > something like an old-school input form: form is displaying a single record > with a listbox showing some child records. When the user deletes a child > record you want the listbox to refresh to show the updated selection. And > the reason you don't want to use entity.reload() is because this would > compel saving changes to the parent/new record. Have I got that right? > Yes, exactly. > > My first thought is why would you allow the user to delete a child record > and NOT save the parent? Just wondering what makes that a problem. (And - > yes I did just ask the equivalent of "why would you want to do that?") > Yes, ultimately whole handling should be wrapped in a transaction and them I could save and reload, but currently I am playing with ideas how to transform things I do in a certain way > Another thought is to manage the selection of child records manually. It's > YEs, I ended with this solution and it is quite low cost. It seems that relation are something like "read only entity selections" and cannot be manipulated, or even refreshed. But it is possible to copy them to normal entity selection. > Yet another thought is to abstract the editing to the equivalent of a > variable and edit the variable. You can use the .toObject() method to > change the contents of a record to an object. This gives you total > That would be unnecessary complex. It is enough to do Form.relatedSelection:=Form.record.relatedRecordsLink and then assign Form.relatedSelection as LB source. Then Form.relatedSelection can be fully manipulated by code. But, when you mentioned .toObject(), I found out that ORDA does not have DUPLICATE RECORD. .clone(), while the name would suggest it is cloning the record, it seems that it just creates another reference to the same record. I do not understand why there is needed .clone() and where simple assignment := would not do. So to actually duplicate record, the looks like $newRecord:=$oldRecord.getDataClass().new().fromObject($oldRecord.toObject()) (maybe there is nicer way) Regards, -- Peter Bozek ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

