Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1413
  • Last Modified:

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

Hi

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;
                  break;
                }
              }
        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?

Thanks.

Ps Sorry for the lack of points. I've ran out.  Any help would be much appreciated!
0
IanWood
Asked:
IanWood
1 Solution
 
Ted BouskillSenior Software DeveloperCommented:
Those values can only be retrieved using XSLT in web parts.  It's not available for the client side JavaScript.
0
 
IanWoodAuthor Commented:
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now