super to sub object

0
I have a domain model where entity type B is a sub-class of entity type A - i.e. B has A as its generalization. Entity B has additional attributes (to A). In a microflow I want to create an object 'b' of type B which has the attributes values of an object 'a' of type A. I then want to set the specialized attributes of 'b' manually. I can see that I can create an object 'b' of type B and set each individual attribute of 'b' from the attributes of 'a'. However, this seems prone to error should I ever add additional attributes to type A. Ideally I would like to change the type 'a' to type B - and then set the additional attributes manually. Is this possible in a microflow? I have looked at inheritance splits but they are not appropriate here, as I understand them. Correct?
asked
3 answers
2

As i have not checked the community commons myself i am not sure if this will cover it. But according to this question it should clone 1 object to another. Perhaps it will allow you to copy your generalization into a specialized object.

Edit: after a small test it does seem to work that way, so give it a shot i'd say :]

answered
0

David

I don't believe there is a way in Mendix to change the type of an object from one entity to another. And yes, you will need to make sure you add any new A attributes to any microflow(s) in which you set attributes of B objects using values from an A object. The 'Find usages' capability in the modeler comes in handy to help with that.

Depending how frequently you plan on doing this in your application, you may want to create one microflow that does the copying, pass this microflow an A object and a B object, and then call that microflow whenever you need to 'clone' in this way. Then you can just call this single microflow from all of the places in the application necessary and, in the future, will just have one place to make any updates required by the addition of attributes to the A entity.

Hope that helps,

mike

answered
0

Thanks, Pieter. I didn't know that library existed. Now I do. I presume there was no native way doing the same thing.

answered