Logged in user to field not working?

I have read numerous threads on this and I think I must be being stupid but I just cannot get it to work correctly.

My form field is called UserName and I have tried the below

In the events

onBeforeInsert -> {UserName} = [usr_login] ;

and I have tried also doing it in the initial value in the field setting

When I run the form it does not load essentially asks me to provide the username before allowing me to carry on to the form.

In the Sec_Users table the UserName is called login so I really cannot see what I could be doing wrong?

A global variable can be “in” or “out”. When you use a global variabnle, automatically defines it in this app as “in” and app is expecting to receive a value.
When you call the form directly from SC, because is expecting this var, it ask you for it for development purposes. Instead to call it directly, run your login app (where [usr_login] is defined), and navigate until your form, and you will see it working.

Take care, on production, if you set a global as “in”, and optional=no, when you call this app, if var is without value, will not ask for a value, instead will throw an error expecting to this variable comes filled.

Thank you makes complete sense.