mike jones
Posts:15
 | | 16 Jul 2010 8:27 AM |
Alert | How would you display the username of the person who created the record? I would like to display the username in a form view with a label so it shows the username of the person who added the record. I see the field 'dnm_UserId' in the database for each table but I can't figure out how to display that int in a form and convert it to the Username.
Thanks!
| | | |
|
Luke Rocco
Posts:262
 | | 16 Jul 2010 11:51 AM |
Alert | Hi Mike,
In order to achieve your requirement, you need to:
Step One- Add a field in the Table to store the Created By value (type Integer).
Step Two- In the form where you Add new entries, place a Label control, set its Data Source to the Created By field, and set it's Label text to {%dnm_userid}.
Step Three- In the View form, place a LabelList control, set its Data Source to the Created By field, and set its List Source to one of the Users List available ( Plain Users List, Surname & Name, or Username ).
Regards,
Luwk | | | |
|
mike jones
Posts:1
 | | 20 Jul 2010 2:33 AM |
Alert | Thanks for the help Luke.
I figured that it could be done the way that you suggested, I was just hoping that I could pull that data from the dnm_UserId field. It seems kind of redundant storing the exact same information in another table column. Is the dnm_ModUserId field not accessible too in form views? | | | |
|
Ruben Gatt
Posts:287
 | | 21 Jul 2010 10:45 AM |
Alert | Hi Mike,
No these are not accessible in form views, its something we might consider for future updates, i.e. of giving access to use the user fields in form views.
Thanks
Ruben | | | |
|
Brian Russell
Posts:51
 | | 29 Jul 2010 4:02 PM |
Alert | Hey Ruben,
Just want to clarify that the user fields are not accessible in either View form or Edit form. Is that correct?
Thanks
Brian | | | |
|
Luke Rocco
Posts:262
 | | 30 Jul 2010 11:01 AM |
Alert | Hi Brian,
If you make use of DNM Queries, you can gain access to the dnm_UserId field. Thus, if you would link your View Form to a DNM Query, you could achieve your target. However as regards to the Edit Forms, you would have to go around it in a slightly different manner.
Regards,
Luwk | | | |
|
Dean Bozzano
Posts:17
 | | 07 Sep 2010 9:08 PM |
Alert | Well, I must me missing something here, because this is not working for me. The manual seems to be a written version of the video tutorials which are great but there appears to be a lot of undocumented techniques and applications in this software.
Are there any obvious potential mistakes in these instructions or things you may not think of setting to make this work? I get a record of the words "Created By" but with a number and not username or display name.
Step One- Add a field in the Table to store the Created By value (type Integer). Step Two- In the form where you Add new entries, place a Label control, set its Data Source to the Created By field, and set it's Label text to {%dnm_userid}. Step Three- In the View form, place a LabelList control, set its Data Source to the Created By field, and set its List Source to one of the Users List available ( Plain Users List, Surname & Name, or Username ). | | | |
|
Dean Bozzano
Posts:17
 | | 07 Sep 2010 9:08 PM |
Alert | Well, I must me missing something here, because this is not working for me. The manual seems to be a written version of the video tutorials which are great but there appears to be a lot of undocumented techniques and applications in this software.
Are there any obvious potential mistakes in these instructions or things you may not think of setting to make this work? I get a record of the words "Created By" but with a number and not username or display name.
Step One- Add a field in the Table to store the Created By value (type Integer). Step Two- In the form where you Add new entries, place a Label control, set its Data Source to the Created By field, and set it's Label text to {%dnm_userid}. Step Three- In the View form, place a LabelList control, set its Data Source to the Created By field, and set its List Source to one of the Users List available ( Plain Users List, Surname & Name, or Username ). | | | |
|
Luke Rocco
Posts:262
 | | 13 Sep 2010 3:12 PM |
Alert | Hi Dean,
Those are exactly the three steps which you need to undertake in order to display the usernames. There are no extra steps requried. What exactly are you getting back from the Label List?
Regards,
Luwk | | | |
|
Dean Bozzano
Posts:17
 | | 13 Sep 2010 8:04 PM |
Alert | Hello Luwk...I see your name is spelled Luke in the profile and you sign Luwk so I apologize if i typed it wrong :) I also see you are all over the boards this morning and thank you for the help on the other areas you have given me and others as well. I have been able to figure out most things and through trial and error have achieved some great results. With a bit of help or more video tutorials much of this can and will get easier.
In fact I think it would almost be easier for us to post a video of our work and show what fields and controls are set to and post to YouTube rather than try and describe here what we are doing and more importantly not describe what we are not doing or doing wrong which makes it impossible for someone like yourself to diagnose. Anyway, your effort is appreciated.
I was not able to get the solution here to work for me. If you say it works just like that, I believe you and I will retry it with a new field later and see if maybe I was doing something wrong.
But in the mean-time I was able to get the intended result in a slightly different way. Let me know if this looks acceptable as a solution as it seems to be working or is there something I may be overlooking?.
Here is what worked for me: I have a table called tb_Measurements in which I added a field called ms_CreatedBy. Field type: Text Field Caption: Created by Field Help: Created by Field size 255 Required set to yes Field order 70 but of no importance here
In my Measurements_Edit form where new records are added: In my template I added the following controls: [DNMLABEL::ID=lblms_CreatedBy] In my Properties I have the lblms_CreatedBy control set as follows: Label Text: {%dnm_username} data Source: ms_CreatedBy
In my Measurements_View form where records are viewed: In my template I added the following controls: [DNMLABEL::ID=ms_CreatedBy] In my Properties I have the ms_CreatedBy control set as follows: Data Source: ms_CreatedBy
This gives me a proper text field showing the record was Created by Host. | | | |
|
Luke Rocco
Posts:262
 | | 22 Sep 2010 5:14 PM |
Alert | Hi Dean,
Try the following and see if you get a similiar answer:
In your table tb_Measurements add a field called ms_CreatedBy_ID. Field type: Number / Integer Field Caption: Created by ID Field Help: Created by ID Field size 255
In the Measurements_Edit form where new records are added: In the template add the following control: [DNMLABEL::ID=lblms_CreatedByID] In the Properties have the lblms_CreatedByID control set as follows: Label Text: {%dnm_userid} Data Source: ms_CreatedBy_ID
In the Measurements_View form where records are viewed: In the template add the following control: [DNMLABELLIST::ID=ms_CreatedByID] In the Properties have the ms_CreatedByID control set as follows: Data Source: ms_CreatedBy_ID List Source: Users List (Display Username)
This should give you a similiar answer to your ms_CreatedBy Label control, but is more flexible since if the user changes his Username (if possible), it will display his latest data.
Regards,
Luwk | | | |
|
Doug Blackmon
Posts:154
 | | 11 Mar 2011 4:19 PM |
Alert | | Would this be the same as who last modified the record or is this for the creator only? | | | |
|
Doug Blackmon
Posts:154
 | | 11 Mar 2011 6:39 PM |
Alert | Luke,
I attempted to use you example above where you are storing the ID of the user in the field created in the table..
However even though I have declared the table field as a INT I am presented with this error every time I try to save the form..
"Input string was not in a correct format.Couldn't store <> in CompanyCreatedBy Column. Expected type is Int32"
Which would suggest the table field I created is either not making it an INT field type in SQL or for some reason the token {dnm_userid} is being passing as text.Thus the reason its complaining about the <> characters in the above error...
So I went ahead and verified in the SQL Management Studio that it is indeed and INT field type so there is not an issue there. I have modified the label to read as [DNMLABEL::ID=lblCompanyCreatedBy::HelpText=::Text={%dnm_userid}] in the HTML because I though the Text area needed to be populated there instead of in the properties of the label. I have also placed the token {%dnm_userid} in the Text value in the Properties field, and I have put it in both the HTML area and the properties area at the same time. I went as far as to strip the extra character off of it so it read as dnm_userid however all methods still present an error for some reason...
So at this point i am very confused because I dont want to store the text value of the user, just the ID.
Doug | | | |
|
Doug Blackmon
Posts:154
 | | 11 Mar 2011 7:50 PM |
Alert | Ok...
Apparently if you already have a live table with data and you create a new field to store the UserID it will populated that field with NULLs giving you the presented error as describe above.
So not the Add form will store the UserID that created the record in that field.
Now on the view form that's a different story... No matter what I do the DNMLABELLIST will not show the text equivalent of the UserID using the example provided by Luke. You can put {%dnm_userid} in the Label Text property and see the ID number of the user, however I am unsure at this moment if that showing me who is currently logged into the portal which I feel that's what its displaying or if that's the value stored in the table.
Regardless there is a flaw somewhere in either the documentation that the example is based on or there is a bug.
Doug | | | |
|
Doug Blackmon
Posts:154
 | | 18 Mar 2011 12:00 AM |
Alert | In closing of this issue it appears since I was doing my development logged in as the Host Account (Super User if you will) and apparently there is something in DNN that will not allow this information to be displayed..
Thanks to Ruben on helping me figure out what was going on. | | | |
|