21
Views
12
Comments
Solved
how to save current user details to database?

Hello,


i have a form where a registered user can fill in with his/her details. But it is unnecessary to fill in the same details everytime you fill in the form. So i was wndering how i can save the details of the current user automaticly everytime the user clicks on the "Save" button on the form. It needs to retrieve the current users details form the outsystems.com/Users page. Is this possible?

This is action of my save button: 

Rank: #1281
Solution

Samed Gurses wrote:

Diksha Wadkar wrote:

Samed Gurses wrote:

Diksha Wadkar wrote:

Samed Gurses wrote:

Diksha Wadkar wrote:

Hello Samed ,

You can store current user data in database by using following steps.

1) Fetch user data using aggregate and put filter on it  User.id=GetUserId()  

2) Assign aggregate values to Create action of your entity .

Hope it helps  !

Thanks & Regards ,

Diksha Wadkar

 

 Hi Diksha, 

the problem is that i dont know what to choose for the variable and value:

the second one, is this going the right way?

 

 Hello Samed,

If you want to store current logged on user id in second assignment  then you can directly use 

GetUserId() build in function in second assignment .

Hope It Helps !

Thanks & Regards ,

Diksha Wadkar

 Hello Diksha,


Actually the items i want to store are : email, name and mobile phone number. Should i make 3 different assignments then? And what should i choose for the value?

 

 

 Hello Samed ,

Please check the following flow diagrams

I have fetched user data using aggregate and i have filtered data of current user .

And createuserdata2() this is my dummy entity action for storing data .I have created entity user2 .

Please check below diagram for assignment .

Hope it helps !


 

 Is it also possible to prefill the input fields? So that the input fields have a initial content allready with for example email of the current user filled in the input?

 

 Hello Samed ,

Yes it is possible .

You need to set input field variable as aggregate value of current user .


Hello Samed,


Yes, you can save the current logged on user details on DB without entering it. Just use an assign widget before saving the data and assign current user's Id by using built in function GetUserId() .

You can also get the User's name or Username by using GetUser(GetUserId()).User.Name GetUser(GetUserId()).User.UserName    respectively.

Hope it helps!


Regards,

Sanjay

Rank: #1281

Hello Samed ,

You can store current user data in database by using following steps.

1) Fetch user data using aggregate and put filter on it  User.id=GetUserId()  

2) Assign aggregate values to Create action of your entity .

Hope it helps  !

Thanks & Regards ,

Diksha Wadkar

Rank: #172

Hi Samed

If your need is to edit the default platform user, see the actions below that can be useful.

Regards.