How to copy value of one textbox to another textbox on chckbox change event

Hi, I am using Mendix Business Modeler 2.5.3. I have an entity which have around 25 attributes in it. In this entity I am storing three type of addresses for customer e.g. home address, office address etc. One address is consist of 6 attributes of the entity. This entity is associated with a DataView where I am inserting the values for all the attributes. On the same page what I want is- When I enter all 6 values for first address then for second address I want a checkbox by clicking on this checkbox I want to populate all the fields of second address as same address as previous. But when I want to add checkbox on my page It complains me that I must associate the checkbox with entity attribute. But I don't need to associate it with any attribute as I just want to copy some fields value to another. And all the fields are attribute of one entity. Please help me how can I achieve this? Thanks Rajnish
2 answers

All 'fields' on your form must currently be based on an attribute in your entity or in an associated entity. (I believe that in future versions it may be possible to have fields based on local variables, but that it not yet available).

So, in your domain model add a boolean attribute (called something like HomeAddressEqualsOfficeAddress) and place it on your form with a label like 'Same as above'.

Create an on change microflow for the boolean field (which passes the current entity to the microflow). In the microflow you can do a Change Object Action where you set HomeAddress to $CurrentEntity/OfficeAddress, etc. Make sure you set the Change Object action to Refresh in client. You might also set the Editability of the HomeAddress attributes based on the value in the boolean field.


In Mendix you always have to select an attribute in case of using a checkbox. You can use this boolean to check if you really want to copy the address values to the second address. If the boolean is true, then you need to call a microflow, which will do the actual copy of the attributes.

This is one way, the other way is by adding a microflow trigger which will do the exact same copy action.