This topic is locked

Put user screenname in DB field

3/31/2004 2:43:42 PM
ASPRunnerPro General questions
author

Hello,
What should I do if I wanted to add the 'current user ' name or creen name (login name) to a field in a table when adding a record?
I suppose it can be done as the username is already somewhere, or else the program could not tell WHO is logged in.
Thank you!
ratti

501056 3/31/2004

aja!

I found the way to do it, I hope it helps someone out there:
Open the "_aspfunctions.asp" for your corresponding table and modify the field which you want to pull the user information for the on-going session:

function GetDefaultValue(strField)

if strField="screenname" then GetDefaultValue = Session("UserID") end if 

end function


Hope it helps someone!
ratti

501057 3/31/2004

Ok, what I posted solves the problem is we are ADDING a new record.
What should we do if we want the current user to be replaced in a field when we EDIT the record.
Lets say that USER1 created the document, thus USER1 will be the Session User when creating so it will be put in that field as default.
What if now USER2 is editing the record, how can I make USER2 the field to be saved over USER1?
Thank you!
ratti

Sergey Kornilov admin 3/31/2004

ratti,
you can do this even easier in ASPRunner. Just go to the Formatting tab and set Default value for this field to Session("UserID").

501058 3/31/2004

thank you, I noticed that after doing it.
What should I do for my second question?

To modify the field when editing?
Thank you!
ratti