Variable default value for string attribute

0
For a course registration I would like the system to default the name of the user in the registration form. However, for a string attribute in the domain model the default value cannot be a variable. How to default the name of the (logged in) user in the registration form?  
asked
8 answers
1

Hi Arjan,

You can create a microflow to open the registration form, and in this microflow you can change whatever you want: including changing a Name string to contain the name of the current user. Retrieve the account using the xpath [id = '[%CurrentUser%]' , and change your registration.name attribute to $Account/Name. Hope this helps!

answered
0

You can achieve this using a BeforeCreation-microflow on the Registration-Entity.

answered
0

Works now, thank you both!

answered
0

Why do you want to store the name in the Registration?

I would opt for a reference to the user and show the name over association.

This also used in the Rapid Developer learning path: http://learn.mendix.com/link/path/10

answered
0

Using an association IS re(use) of data instead of duplicating it what you try to achieve.

And also this can be set automatically, just like Wieke described. But instead of copy/pasting the name in a attribute, you can set the association to the current logged-in user. 

Additionally, split your account data (ability to login) from process data (who you are in a process)

See this topic: https://forum.mendix.com/link/questions/88682

answered
0

Got it. Thanks for your valuable input. After making the suggested changes I keep on getting the following message:

Do you have any idea how to fix this?

answered
0

Hi Arjan,

For the New button which Invokes a Custom MF I believe,
 

1. Change this MF - remove the input parameter RegistrationForm from the MF.

2. You need to add a "Create Object" activity before "Retrieve Account from Database" in your MF. This will create a new "RegistrationForm" object before associating it to an account retrieved. 

 

answered
0

Works like a charm now. Thanks Abhishek for the solution and explanation.

answered