ksa
Posts: 27
|
Posted: 02/09/2013, 2:08 PM |
|
I'm failing to do what I think should be a very simple thing, but apparently I'm just too dense.
I want to insert the username of the currently logged in user into a record. I can make the username show just fine outside the record form by simply adding a {UserLogin} (as in "Welcome to your account {UserLogin}), but no matter what I do, I can't make the username appear inside the record, let alone in a hidden field that's inserted into the database, like I want to.
What would be the proper way to do it? I've tried so many things I can't even begin to mention them, but it's all in vain.
Any help would be truly appreciated. I'm using CCS 5.
|
|
|
DataDoIT
|
Posted: 02/09/2013, 5:44 PM |
|
Put a hidden field anywhere within the confines of your record form.
For the hidden field control, in it's Before Show add action 'Retrieve
Value for Control'. For Source Type choose Expression. For Source Name
enter CCGetUserLogin().
|
|
|
ksa
Posts: 27
|
Posted: 02/10/2013, 9:23 AM |
|
Thank you so much! Your help is much appreciated. I knew it was simple.
|
|
|
Lucius
Posts: 220
|
Posted: 02/11/2013, 6:16 AM |
|
DataDoIT is a good way if you trust the form input.
However if you can imagine situation when you do not trust the form data (for example the user name is security-crucial), do this by using Custom Insert and Custom Update SQLs, where you can define the function that will fill a field that is not on the form shown.
Second way is to use Before Execute Insert and Before Execute Update events to add this information to the DB.
This way it is done server-side and user cannot change the hidden control value, which is very easy to do.
You can also add validation for the form that will check if the form User Name is the real User Name, but this is more work, instead of doing the 2 possible solutions I wrote above.
|
|
|
DataDoIT
|
Posted: 02/11/2013, 9:56 AM |
|
Lucius is correct. What he's referring to is that 'username' will be
visible in the code (View Source) and passed as clear text. If that's
an issue, then the next easiest way without coding would be to do a
Custom Insert/Update and add the value there.
Choose the record form in CCS, choose Properties -> Data. Select the
build button next to the Custom Insert/Update properties. Choose the
Get Form Controls button to let it populate what it sees, then choose
the Plus button to add your extra parameter.
Field: username
Type: Text
Paramater: CCGetUserLogin()
Type: Expression
|
|
|
ksa
Posts: 27
|
Posted: 02/12/2013, 1:29 PM |
|
Thanks for the suggestions. I will look into them some more when I have time. Just want to add that security is of course an issue, but for now the input field must also validate as an email address (because in this case the username equals people's email address). Not sure how secure that is, but it's something.
|
|
|
niiantiaye
Posts: 9
|
Posted: 02/28/2013, 10:05 AM |
|
DataDoIt , I tried using the Custom Insert/Update method. I added a record but when I looked through the database the username field was empty. Please what am I missing ?
|
|
|
|