Automatically capturing a user's identity in a form

Happy Boxing Day 2018! I have a short question about automatically capturing a user's identity in a form.


I have a form in which a user must answer all the questions (including his name!), submit, and have all his answers captured in the database. Although the form works, it is weird that the user must specify his name in the form when the app already knows that this is HIS login session. I removed the "name" input but it broke the logic at runtime. How can I remove the "name" input properly?


In case it helps, my form screen uses the aggregates GetENTITYById and GetUsers.

You can get username from the entity "User" in the System, by filter it using GetUserId()

Approach 1:

You can do one thing.

In your preparation, you can get Username by using GetUsers aggregate then assign the name that you got from aggregate to Name input field variable and make this input field disable.

So in the form you will have all the fields enabled except Name field which will have Username pre filled and will be disabled.


Approach 2:

As you mentioned, you are using getENTITYbyId to get the data and populating the form. so you can get UserId in preparation and assign it to UserName attribute in getENTITYbyId record, now you don't need to have username field on screen so you can remove it. 

when you submit the form get all the details from form fields except username (which you already got in preparation and saved it in record attribute).


Hope this helps.


Hi YS,

What I used to do is this:

I go to the beginning of "Save" screen action, put an If to question if is new (***Id = NullIdentifier()), and if yes, I put an assign that insert in the attribute that I want the UserId. If you just want the name you can use something like:


Hope this idea can help you.


Regards,

Ricardo

Manoj Ahirwar wrote:

Approach 1:

You can do one thing.

In your preparation, you can get Username by using GetUsers aggregate then assign the name that you got from aggregate to Name input field variable and make this input field disable.

So in the form you will have all the fields enabled except Name field which will have Username pre filled and will be disabled.


Approach 2:

As you mentioned, you are using getENTITYbyId to get the data and populating the form. so you can get UserId in preparation and assign it to UserName attribute in getENTITYbyId record, now you don't need to have username field on screen so you can remove it. 

when you submit the form get all the details from form fields except username (which you already got in preparation and saved it in record attribute).


Hope this helps.



Thanks! What do you mean by "get UserId in preparation"? Means "On Initialize"?

Solution

YS Yeo wrote:

Manoj Ahirwar wrote:

Approach 1:

You can do one thing.

In your preparation, you can get Username by using GetUsers aggregate then assign the name that you got from aggregate to Name input field variable and make this input field disable.

So in the form you will have all the fields enabled except Name field which will have Username pre filled and will be disabled.


Approach 2:

As you mentioned, you are using getENTITYbyId to get the data and populating the form. so you can get UserId in preparation and assign it to UserName attribute in getENTITYbyId record, now you don't need to have username field on screen so you can remove it. 

when you submit the form get all the details from form fields except username (which you already got in preparation and saved it in record attribute).


Hope this helps.



Thanks! What do you mean by "get UserId in preparation"? Means "On Initialize"?

Sorry i missed that you were talking about Mobile App. so in that case 

- you can get the UserId/Username just before saving. or

- On Initialize, get the Userid/username from the session.


Solution