This project has moved and is read-only. For the latest updates, please go here.

Using "GetListItems" in a custom display form

Mar 16, 2011 at 11:05 AM

Hi all,

I'm trying to use the GetListItems function in a custom display form in order to show addional information. But unfortunately the whole javascript code is ignored and I don't know why.

Here is the code:

<script language="javascript" type="text/javascript">
$(document).ready(function() {
operation: "GetListItems",
async: false,
listName: "{7D5A5390-B0F3-41F1-980A-DB995B30E4D2}",
webURL: "",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /></ViewFields>"
completefunc: function (xData, Status) {
$(xData.responseXML).find("[nodeName='z:row']").each(function() {
var liHtml = "<div>" + $(this).attr("ows_Title") + "</div>";

</script><div id="WSOutput"/>


The alert is for testing. If I put the code as above on the page, the alert doesn't show. If I comment the line with the CAMLViewFields and the completefunc out I at least get the alert. So I think that there has to be the error but I can't find it. Maybe someone here has a hint for me?



Mar 16, 2011 at 12:39 PM
You need a comma after the CAMLViewFields line. Hopefully that's the only issue; it's the first thing I spotted.
Mar 16, 2011 at 1:07 PM

I've also spotted a missing semicolon after the alert:


I'm assuming you've closed the script tag as well, but your code doesn't show that either.  If it's not there already, you'll want to append </script> to the end of
your code as well.

Mar 16, 2011 at 1:14 PM
Edited Mar 16, 2011 at 2:10 PM

I added the comma after the CAMLViewFields and the semicolon after the alert, but without success:o(

The closing tag for the script ist there. It's in the last line with the div. I used the function on a "normal" webpart page without any problems, so I first thought I can't use it here?



Mar 16, 2011 at 3:29 PM

I think you are saying you have the <script>.....</script> within a <div> element.  Move this <script> tag up to the <head> and try that.

Mar 16, 2011 at 3:59 PM

I can't believe it, it works! I put the javascript code bevor the DFWP (I can't put it into the head section, because I have no access to to the masterpage) and the scripts works. I would never have thought about that because when I used this function the last time I put it before the div tag too and it worked.

Thanks you both for your help!

Mar 16, 2011 at 4:01 PM


I like to put my script stuff right under the line:

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

I try to be consistent so that I always know where to look.


Mar 16, 2011 at 4:21 PM

I should do this, too... I try to put the code in one place but sometimes I forget it. But I think after this I will never forget it :)