Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. SharePoint
  4. User Field type

User Field type

Scheduled Pinned Locked Moved SharePoint
tutorial
14 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Ingo

    So that ist no question. Where do you stuck? By the way, before answering the untold question you should answer, where the manager is stored? Do you have this Information in AD (every User has a department, someone is manager of the department), do you have a database with this information, do you have MetaData about it? Or do you habe a simple List? So, perhaps you see, there are many ways for reaching the aim, of displaying the manager of a user.

    ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

    A Offline
    A Offline
    Aptiva Dave
    wrote on last edited by
    #3

    All my users are in AD.

    I 1 Reply Last reply
    0
    • I Ingo

      So that ist no question. Where do you stuck? By the way, before answering the untold question you should answer, where the manager is stored? Do you have this Information in AD (every User has a department, someone is manager of the department), do you have a database with this information, do you have MetaData about it? Or do you habe a simple List? So, perhaps you see, there are many ways for reaching the aim, of displaying the manager of a user.

      ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

      A Offline
      A Offline
      Aptiva Dave
      wrote on last edited by
      #4

      Sorry, didn't realize that I didn't actually ask a question. My bad. :laugh: :laugh:

      I 1 Reply Last reply
      0
      • A Aptiva Dave

        Sorry, didn't realize that I didn't actually ask a question. My bad. :laugh: :laugh:

        I Offline
        I Offline
        Ingo
        wrote on last edited by
        #5

        Ok, I guessed what do you want, but it would be good to describe the problem and what do you already did. :-\

        ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

        L 1 Reply Last reply
        0
        • A Aptiva Dave

          All my users are in AD.

          I Offline
          I Offline
          Ingo
          wrote on last edited by
          #6

          Ok, next question is, if you have synchronized the user profile service with the ad. If it is synchronized all data is there. You just habe to read it:

          using (SPSite Site = new SPSite(“Site URL”)) {
          using (SPWeb Web = Site.OpenWeb()) {
          SPList UserInfoList = Web.Lists[“User Information List”];
          SPUser User = Web.Users.GetByID(1); – Put the User ID Here
          SPListItem UserItem = UserInfoList.GetItemById(User.ID);
          ...
          }
          }

          You can read the Department with:

          UserItem[“Department”]

          Afterwards you read the "Job title" for all the Users in the department (same way) and look up the head of the deparment. Perhaps it's not in the job title but in another field, depending on how the information in the ad is filled. Well, so that how to do it with informations in the ad.

          ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

          A 2 Replies Last reply
          0
          • I Ingo

            Ok, next question is, if you have synchronized the user profile service with the ad. If it is synchronized all data is there. You just habe to read it:

            using (SPSite Site = new SPSite(“Site URL”)) {
            using (SPWeb Web = Site.OpenWeb()) {
            SPList UserInfoList = Web.Lists[“User Information List”];
            SPUser User = Web.Users.GetByID(1); – Put the User ID Here
            SPListItem UserItem = UserInfoList.GetItemById(User.ID);
            ...
            }
            }

            You can read the Department with:

            UserItem[“Department”]

            Afterwards you read the "Job title" for all the Users in the department (same way) and look up the head of the deparment. Perhaps it's not in the job title but in another field, depending on how the information in the ad is filled. Well, so that how to do it with informations in the ad.

            ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

            A Offline
            A Offline
            Aptiva Dave
            wrote on last edited by
            #7

            I'm not trying read info (yet), I'm just trying to add to the list. So, here is what I'm using on the form:

            <SharePoint:PeopleEditor ID="sppeManager" runat ="server" MultiSelect ="false" />

            Here is my field:

            And here was the code I was trying to use to insert the value from the form into the field:

            Dim managerID As SPFieldUserValueCollection = New SPFieldUserValueCollection()
            Dim manager As String = sppeManager.Entities(0).ToString
            site.EnsureUser(manager)
            Dim mgrAccount As SPUser = site.SiteUsers(manager)
            Dim mgrID As New SPFieldUserValue(site, mgrAccount.ID, mgrAccount.LoginName)
            managerID.Add(mgrID)
            item(AccessRequest.ManagerCol) = managerID

            But, this isn't working at all. I just can't get anywhere and I can't find a reliable tutorial online to help me.

            I 1 Reply Last reply
            0
            • I Ingo

              Ok, next question is, if you have synchronized the user profile service with the ad. If it is synchronized all data is there. You just habe to read it:

              using (SPSite Site = new SPSite(“Site URL”)) {
              using (SPWeb Web = Site.OpenWeb()) {
              SPList UserInfoList = Web.Lists[“User Information List”];
              SPUser User = Web.Users.GetByID(1); – Put the User ID Here
              SPListItem UserItem = UserInfoList.GetItemById(User.ID);
              ...
              }
              }

              You can read the Department with:

              UserItem[“Department”]

              Afterwards you read the "Job title" for all the Users in the department (same way) and look up the head of the deparment. Perhaps it's not in the job title but in another field, depending on how the information in the ad is filled. Well, so that how to do it with informations in the ad.

              ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

              A Offline
              A Offline
              Aptiva Dave
              wrote on last edited by
              #8

              Also, I'm using this information to start a workflow.

              1 Reply Last reply
              0
              • A Aptiva Dave

                I'm not trying read info (yet), I'm just trying to add to the list. So, here is what I'm using on the form:

                <SharePoint:PeopleEditor ID="sppeManager" runat ="server" MultiSelect ="false" />

                Here is my field:

                And here was the code I was trying to use to insert the value from the form into the field:

                Dim managerID As SPFieldUserValueCollection = New SPFieldUserValueCollection()
                Dim manager As String = sppeManager.Entities(0).ToString
                site.EnsureUser(manager)
                Dim mgrAccount As SPUser = site.SiteUsers(manager)
                Dim mgrID As New SPFieldUserValue(site, mgrAccount.ID, mgrAccount.LoginName)
                managerID.Add(mgrID)
                item(AccessRequest.ManagerCol) = managerID

                But, this isn't working at all. I just can't get anywhere and I can't find a reliable tutorial online to help me.

                I Offline
                I Offline
                Ingo
                wrote on last edited by
                #9

                Aptiva Dave wrote:

                I'm not trying read info (yet), I'm just trying to add to the list.

                ??? You try to read the Info and add it to the list. Therefore is the code I wrote. Fill the Field with an EventListener.

                ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

                A 1 Reply Last reply
                0
                • I Ingo

                  Aptiva Dave wrote:

                  I'm not trying read info (yet), I'm just trying to add to the list.

                  ??? You try to read the Info and add it to the list. Therefore is the code I wrote. Fill the Field with an EventListener.

                  ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

                  A Offline
                  A Offline
                  Aptiva Dave
                  wrote on last edited by
                  #10

                  Well, that's going to be an issue because some people report to someone who isn't labeled as a manager in AD. This is because a) in some large departments it is just a title and doesn't really mean anything and b) IT doesn't usually get notified of when someone is made a manager or supervisor so that we can make the changes in AD nor do our users usually make use of the tools we have given them to make the changes themselves. So, since all I can rely on AD for is their user account and email address, I would like to have the people picker on the form to allow the user to at least find their manager's name and let the site handle the rest. I hope that makes sense.

                  I 1 Reply Last reply
                  0
                  • A Aptiva Dave

                    Well, that's going to be an issue because some people report to someone who isn't labeled as a manager in AD. This is because a) in some large departments it is just a title and doesn't really mean anything and b) IT doesn't usually get notified of when someone is made a manager or supervisor so that we can make the changes in AD nor do our users usually make use of the tools we have given them to make the changes themselves. So, since all I can rely on AD for is their user account and email address, I would like to have the people picker on the form to allow the user to at least find their manager's name and let the site handle the rest. I hope that makes sense.

                    I Offline
                    I Offline
                    Ingo
                    wrote on last edited by
                    #11

                    Ok, you just want to have a field, where the User of the form can put in the one, who is manager, right? There are different solutions. 1. You go a different way and build a list of managers for each department 2. You let the user enter a name in a normal user-field 3. You fill a dropdownbox with all users of the department, so that the selection is smaler (for this case you can use the code I wrote before, just that you add every member of the department to the dropdownbox). Hope, there is a solutions suitable for you.

                    ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

                    A 1 Reply Last reply
                    0
                    • I Ingo

                      Ok, you just want to have a field, where the User of the form can put in the one, who is manager, right? There are different solutions. 1. You go a different way and build a list of managers for each department 2. You let the user enter a name in a normal user-field 3. You fill a dropdownbox with all users of the department, so that the selection is smaler (for this case you can use the code I wrote before, just that you add every member of the department to the dropdownbox). Hope, there is a solutions suitable for you.

                      ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

                      A Offline
                      A Offline
                      Aptiva Dave
                      wrote on last edited by
                      #12

                      Well, the big wrinkle is that we have anonymous access on the site and don't allow users to log in, so that is why I was going to used the People editor control so the user could find their manager's name from our AD environment.

                      1 Reply Last reply
                      0
                      • I Ingo

                        Ok, I guessed what do you want, but it would be good to describe the problem and what do you already did. :-\

                        ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #13

                        Which version sharepoint are you using, 2007 or 2010? www.jadesum.com

                        I 1 Reply Last reply
                        0
                        • L Lost User

                          Which version sharepoint are you using, 2007 or 2010? www.jadesum.com

                          I Offline
                          I Offline
                          Ingo
                          wrote on last edited by
                          #14

                          SharePoint 2010 :-\

                          ------------------------------ Author of Primary ROleplaying SysTem How do I take my coffee? Black as midnight on a moonless night. War doesn't determine who's right. War determines who's left.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups