Accessing System.users in the application

0
Hey there, I'm kinda new to the platform and I'm creating a portal, where a user after logging in can post a job, which other users can view. For this, I created multiple local users, which can then log into the application. However, when they create a job, how can I get the User Detail so I can save it in the job object.  Right now, I have created a User entity and set 'System.User' in its generalization property. Since this entity is associated to the Jobs entity, I can Access the User's attribute on the Jobs page, However, when I run the application, I get a null value. Can someone suggest me the best way to perform this - to access the local user information and save it in another object.
asked
4 answers
2

Hi,

An association is not set automatically. Is an optional member of the owning entity (dotted side of the association - in this case the Job)

If the association to the current user must be set at the moment the job is created (or saved) then this can be handled in a microflow. This microflow will retrieve the current UserProfile and associate it from the Job.

such microflow would look like this: https://modelshare.mendix.com/models/8626c714-fff3-4a21-a42e-71f81df95f09/after-create-set-job-user-profile​

Mendix uses the object ID's automatically and therefore it is not needed to create your own ID's Such as Job_ID and ProfID.
Also using _UnderScores in your Attribute and Entity names will cause unreadable XPaths, so advise is not to use them.

In that case, your domain model would look like this;

 

Best, Rene

answered
1

Hi,

Rene gives a great and detailed answer. I would just like to add that in this particular case where you want to store a reference to the account that created an object "Job" in your case, you can use the store owner functionality

You can then use the owner in microflows and on pages:

Have a nice evening,

Andrej

 

answered
0

Abishek,

 

I think the problem you are running into, is that you are using the Mendix standard save button on that form. The standard save button will just commit the object "Job" in this case, but what you want to accomplish is to commit "job" and set an association to a user or the current user. Similar to what Rene said, you need to set the association user profile to Job. To accomplish this, you should use an action button instead of a save button on the form. The action button will call a microflow that passes the job object as a parameter. You will need to retrieve the current user account and then set the association to the user account and then commit the object. 

 

Here is an example microflow - https://modelshare.mendix.com/models/fbe3caf5-692e-4a1b-80cf-e04e44f555be/example-microflow-for-forum-question-88290

 

Here is a link that explains how to import a microflow from model share. https://docs.mendix.com/refguide6/model-share

 

Additionally, regarding your domain model, you may be able to accomplish the same thing without making an entity called "User_Profile" but rather use a cross module association to the admistration.Account table. 

 

 

 

 

answered
0

As addition: two important links with valuable input for your challenge:

Online Learning module about the Domain model: https://gettingstarted.mendixcloud.com/link/module/4/lecture/172

Forum topic regarding the use of the User entity: https://forum.mendix.com/link/questions/88247

answered