269
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: 

UserImage.jpg
Diksha Wadkar
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 .


UserImage.jpg
Samed Gurses

Diksha Wadkar wrote:

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 .


 i did that but than the email adress and other details are not correctly passed to the database: 

 you see for example that the email adress is empty, however it was pre filled with currents users email.

2020-07-29 19-08-40
Sanjay Kumar Sahu

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

UserImage.jpg
Samed Gurses

Sanjay Kumar Sahu wrote:

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

 

 I allready have a assign so i need to add a new one. But the problem is that i do not know what to select for the variable and value. I have this right now, the second one: 

Is this good? What should i choose for the value

UserImage.jpg
Diksha Wadkar

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

UserImage.jpg
Samed Gurses

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?

2021-06-09 13-39-18
Agno Silveira
 
MVP

Hi Samed

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

Regards.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.