0

Using Sharepoint Designer 2010 and no access to Foundation, VB, or installation of third-party software, is it possible to do the following:

  1. I have a People or Group column called Student Name. It allows the users to search our AD database and captures the name.
  2. I would like a second column next to it, called Student Email, that auto fills the email associated with the person in Student Name.

Unfortunately, I don't have access to making customized code, but might be able to inject Javascript with a little help.

Is there any way to do this dynamically?

2 Answers 2

2

You can leverage SPServices http://spservices.codeplex.com/. Download the js library file and upload it into a SharePoint library (ex Site Assets)

Then edit the page in question, add a content editor webpart and link the JS files.

Now handle the onchange event of the text box where the search is happening, then use SPServices http://spservices.codeplex.com/wikipage?title=GetUserProfileByName method to get additional information of the selected user.

And populate the email of the selected user.

10
  • Does this work for normal lists? I'm just looking to edit a list, not a separate page. Commented Jan 12, 2015 at 15:26
  • Yes you can edit the list (new/edit form) page and add a script editor webpart. You can use browser developer tools to find out the html tag id's for hooking up the events. Commented Jan 12, 2015 at 15:28
  • Thank you. Could you explain the Javascript in your answer a bit more? I'm still a beginner at Javascript unfortunately. Commented Jan 12, 2015 at 15:35
  • Ok. The SharePoint page you are talking about is rendered as HTML objects. The people control is a text box where users can type. So using JavaScript add a keydown event handler and capture the data. In the same handler using the value in the textbox, invoke a SPServices call to getuserprofilebyname. This will return you the details of the selected user in XML format. You can use that to find the Email and populate another element (ex a textbox) Commented Jan 12, 2015 at 15:38
  • Thank you for that explanation. I may be grabbing the wrong code but I don't believe this is working. Do you mind looking over my code? Commented Jan 12, 2015 at 16:53
0

Using the SPJS Utility and SPJS Autocomplete libraries, I was able to implement this dynamically with the following code:

//intialize fields fields = init_fields_v2(); //Autocomplete email column from name column spjs.ac.peoplePicker({ "applyTo":"Student_x0020_Name", "forceOn2013":false, "helpText":"Enter name or email address...", "showField":"Title", "chooseFromUserGroup":null, "showUsersOnly":true, "rowLimit":5, "listOptionsOnFocus":false, "reValidateOnLoad":false, "setFields":[ { "fromFIN":"EMail", "toFIN":"Student_x0020_Email", "skipIfEmpty":false } ] }); 
2
  • Nice to hear you completed the task! Cheers!!! Commented Jan 14, 2015 at 14:59
  • Thank you! My knowledge of Javascript is limited so I appreciate all your help. Commented Jan 14, 2015 at 15:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.