Can I use five.currentUserKey() function in a Form field Default Value?

Hi all. I’m back after a long break… I know I can do this with a function called on “Do Before Insert” but for simplicity, is it possible to set the value of “five.currentUserKey();” as a Default value in my Form?

I tried but when I save the record in my application, I get this error message: “Could not map formfield ‘iUserKey’ to table ‘TimeSheet’. Got 0 formfields instead of 1”. I tried many different Display Type (User_ID, _Identifier…) in this field with no success. Thanks!

Hello,

Yes this is possible, you will need to remove the quotation marks from the function.

So the code in Default Value should read as

=five.currentUserKey()

Hope this helps,
Thanks,
Riley.

Ok thank you, it works fine for a user when its role has no Security Table.

However, if I set the Security Table and the User Table to IUser,

and start the program, as expected the IUserkey does not show up.

But still, I have this message:

Hello Jean,

There should be no need to set the Security Table and User Table to iUser, ultimately, you should have another table called Employee which is linked to this menu. Then when you create a user (i.e. create an employee), you assign them to one of the employee records.

I have previously created a multi-user application. In this photo^^, I am logged in as admin. I have created various distributors where I have assigned them to a ‘User Record’ in which comes from the Distributor table.

If you would like a more in depth explanation, just let me know! I can also send you this application as a reference if you’d like.

Thanks,
Riley.

Hello Riley. Thanks for your explanation. Yes sending me this application would be very appreciated. I must admit the multiuser aspect is a somewhat difficult concept to master for me.

Hello,

Here is the FDF for the Distributor Management System.

DisManagement-20241210-213955738319905.fdf (6.3 MB)

ADMIN ACCOUNT
Username: admin
Password: BlackDuck&22

MANAGEMENT
Username: management
Password: management1!

DISTRIBUTOR ONE
Username: distributor
Password: distributor1!

DISTRIBUTOR TWO
Username: distributor2
Password: distributor2!

Above are the log in details for the various accounts. From admin, you can see both the management menu and distributor menu as well as a Users menu, within the Users menu, you can create new users, assigning them to either the role of Management or Distributor.

Have a look and see you how you go, let me know if there is any issues with the app or if you would like some further explanation,

Hope this helps,
Thanks,
Riley.

1 Like

OK, the Distributor Management System application is very useful. It helps me make the concept clear. Now I understand better the relation between the Role “User Table Key Field”, the IUser IUserRecordKey field, and the IUser from field “User Record”. Thanks you very much!

I encountered an issue while playing with the Distributor Management System application.

Here are the steps I followed:
1- Run the app
2- Sign in as “distributor”
3- Select Inventory
- I can see 3 items as expected
4- Run again the app in a new browser tab (I use Firefox)
5- Sign in as “distributor2”
6- Select Inventory
- I can see 0 item as expected
7- Go back to the tab where “distributor” is running
8- Select Dashboard
9- Select Inventory
Expected: 3 items displayed
Actual: 0 item displayed

If I logout both users, and logon with “distributor”, now the inventory is properly displayed.

My theory is that the value of the parameter five.stack.Distributo.DistributorKey is shared upon both users, which it should not. Am I correct?
Is it a bug or simply that the application must not be launched on the same browser with more than one user?

Thank you!

Hello Jean,

Thanks for picking up on this! I will take a look into why this happens and get back to you,

Riley.

Also glad to see this helped! Please let me know if you have any further questions.

Thanks,
Riley.

Hello again,

This issue occurred as you cannot have two users logged into the same browser on the same machine at the same time. If you log the two users in on two different browsers (for example, Google and FireFox) it will work fine.

This is currently not an issue as there is no use case where two users should be logged into an application on the same browser on the same machine. A website session is also always shared amongst tabs, and therefore, you can only have a single session per browser.

Potential work arounds include incognito mode of the browser, or using two different browsers.

Hope this helps!

Thanks,
Riley.

1 Like