Sharepoint Designer Javascript - Getting The Value Of "Person Or Group" And "Lookup" Type Fiields.

Posted on 2009-12-18
Last Modified: 2012-05-08

I'm using the following function I found on the internet to get the values of sharepoint fields:-

function getTagFromIdentifierAndTitle(tagName, identifier, title, option) {
  var len = identifier.length;
  var tags = document.getElementsByTagName(tagName);
  for (var i=0; i < tags.length; i++) {
    var idString = tags[i].id;
    var nameString = tags[i].name;
    // get selected radio button value only
    if (option == "value" && tags[i].type == "radio" && (identifier == "RadioButtons" && nameString.indexOf(identifier) == nameString.length - len)) {
      var tagParentHTML = tags[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.innerHTML;
        if (tagParentHTML.indexOf('FieldName="'+title+'"') > -1) {
              var radioButtons = document.getElementsByName(nameString);
              var radioValue = "";
              for (var x=0; x < radioButtons.length; x++) {
                if (radioButtons[x].checked) {
                      radioValue = radioButtons[x].parentElement.title;
        var o = document.createElement("INPUT");
        o.type = "hidden";
        o.value = radioValue;
          return o;
    // get radio buttons group
    if (tags[i].type == "radio" && (identifier == "RadioButtons" && nameString.indexOf(identifier) == nameString.length - len)) {
      var tagParentHTML = tags[i].parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.innerHTML;
        if (tagParentHTML.indexOf('FieldName="'+title+'"') > -1) {
              return document.getElementsByName(nameString);
      // all other input or select type
    else if (tags[i].title == title && (identifier == "" || idString.indexOf(identifier) == idString.length - len)) {
       return tags[i];
  return null;

it's working fine for most field types, but not for "Lookup" Or "Person Or Group",

I'm calling it with:

  var business_area = getTagFromIdentifierAndTitle("select","Lookup","Business Area","");

i've tried various combination now, but no luck.

Any advice please?


Ps Sorry for the lack of points. I've ran out.  Any help would be much appreciated!
Question by:IanWood
    LVL 51

    Accepted Solution

    Those values can only be retrieved using XSLT in web parts.  It's not available for the client side JavaScript.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
    The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now