GetListItems - get rid of the ID number that shows up

Apr 26, 2012 at 5:53 PM
Edited May 1, 2012 at 7:53 PM

I am working in sharepoint 2007. I am wanting to pull just the username from the people option. The column PictureDetails is using Allow selection of: People only  and show field User name. 

Basically I just want to pull the employees username using getlistitems. It is working just fine, except the information that renders shows this    42;#tx23494   How do I get rid of 42;#. I only want tx23494 to render so I can have the html pull their photo, blog, and profile. Here is my code:

This is from the xml file

  <z:row ows_Attachments="0" ows_LinkTitle="Picture with details" ows_PictureDetails="42;#tx23494" />

This is my code:

<link rel="stylesheet" href=".........../memberinto/style.css" type="text/css" />

<script type="text/javascript" src="........../js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="........./jquery.SPServices-0.7.1a.min.js"></script>

<ul id="tasksUL"><li>HELLO! Welcome to Connect Community</li></ul>

<script language="javascript" type="text/javascript">

  operation: "GetListItems",
  async: false,
  listName: "{......}",
  CAMLViewFields: "<ViewFields><FieldRef Name='PictureDetails' /></ViewFields>", 
   completefunc: function (xData, Status) {

   alert("Sending the xml request to the server was: " + Status);
   alert("Sharepoint processing of the message returned: " + xData.responseText);

   $(xData.responseXML).SPFilterNode("z:row").each(function() {
 var liHtml ='<li>Created: '+$(this).attr('ows_PictureDetails')+'</li>';



Apr 26, 2012 at 6:15 PM

Here's how I peel off the ID and delimiter in onne place in SPServices:

      var splitValue = thisValue.split(";#");
      thisOptionId = splitValue[0];
      thisOptionValue = splitValue[1];


Apr 26, 2012 at 6:19 PM

Thanks!! Where do I insert this into the code. I have tried several options and it is not rendering

Apr 26, 2012 at 6:24 PM

var splitValue = $(this).attr('ows_PictureDetails').split(";#");
var liHtml ='<li>Created: '+ splitValue[1] +'</li>';

Apr 26, 2012 at 6:25 PM

THANK you so much. This works!! I appreciate it

Apr 26, 2012 at 6:28 PM

You bet.


Apr 30, 2012 at 8:50 PM
Edited May 1, 2012 at 7:51 PM

This is working great! Thanks,

one more question: I am wanting to add a conditional statement and am having trouble making it work. On the form in sharepoint I have a radio button that gives them the option if they want to introduced to the community. They select a yes or no radio button. If they select yes, then the code above will display their information. I need to add to the code above a conditional statement.

Apr 30, 2012 at 9:05 PM
Edited May 22, 2012 at 3:01 AM

This line isn't valid:


It's not clear if you are trying to set it or get it, but my guess is that you've got an eror there.


Apr 30, 2012 at 9:20 PM
Edited May 1, 2012 at 7:50 PM

thanks for your help

Apr 30, 2012 at 10:21 PM

I see quite a few more mistakes in your script, but the main one is that you are checking the radio button outside the $(document).ready(). The element may well not be in the page when you check it. You also probably want to bind to the change event for the radio button rather than just checking it on page load.


May 18, 2012 at 8:29 PM

I have tried a couple different ways, but this is my favorite since it can be used on fields with multiple users without ignoring half the array.
I'm interested in opinions on draw backs for this method.

//used to get rid of the 123;# at the beginning of many sharepoint fields
String.prototype.fixName=function(){return this.replace(/[0-9]{1,};#|#/g,"")}

var fixedValue= $(this).attr('ows_PictureDetails').fixName();
var liHtml ='<li>Created: '+ fixedValue +'</li>';

might be mistaken here, because it's been a few weeks since I used it.
results should look something like this:

for one user

for three users
	value; value; value

you can then split this like so:

results in