Create an order to logged user

HI all,

I have an order table and a user table. in user table I have the column email, and when I create a new order I'd like the user's name to be automatically added to the order table based on the email logged into the app.

e.g.:

USER_TABLE

USER_IDNAMEEMAIL
1Johnjohn@a.com
2Marymary@g.com

ORDER_TABLE

ORDER_IDFK_USER_ID
  

In the app when John is logged and he click on new order button, automatically, the USER_ID = 1 is added to FK_USER_ID on the ORDER_TABLE and the NAME = John is displayed on the Name. 

i.e. that the reference between the tables is displayed on the screen based on John's e-mail (logged into the system) and that when the operation is saved the information is added to the database, as follows.

ORDER_TABLE

ORDER_IDFK_USER_ID
11

Thank you.

 

Solved Solved
0 4 60
1 ACCEPTED SOLUTION

For starters set the security filter for USER_TABLE to:

[EMAIL] = USEREMAIL()

Then in the [FK_USER_ID] column initial value setting set a formula like this:

ANY(USER_TABLE[USER_ID])

 I would also suggest to set the 'Editable if' setting of this column to FALSE (make sure you don't just uncheck the box, you actually need to write FALSE into the setting once you uncheck the box).

View solution in original post

4 REPLIES 4

For starters set the security filter for USER_TABLE to:

[EMAIL] = USEREMAIL()

Then in the [FK_USER_ID] column initial value setting set a formula like this:

ANY(USER_TABLE[USER_ID])

 I would also suggest to set the 'Editable if' setting of this column to FALSE (make sure you don't just uncheck the box, you actually need to write FALSE into the setting once you uncheck the box).

Hi Markus,

Thanks for your help. It doesn't work because the user_ID was visible on screen, but when I save it was not saved on data base.

 


@caburity wrote:

It doesn't work because the user_ID was visible on screen


Not sure what you mean by this. You don't want to show this in your form? If so then set the show if constraint for the column. If the column populated on the form correctly but the value was not saved to your database then you will want to check the audit log if there are any errors that show up. Screenshots help to better explain your issues also.

Thank you Markus, it works. It wasn't because of my mistake. ๐Ÿ‘

Top Labels in this Space