0

I know there are a few questions out there already, but I can't seem to get any of them to work. Please help.

$(document).ready(function() {

  $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Question Archive / Archive des questions",
    CAMLViewFields: "<ViewFields><FieldRef Name='My Question / Ma questions' /><FieldRef Name='Answer' /></ViewFields>",
    completefunc: function (xData, Status) {
      $(xData.responseXML).find("z\\:row, row").each(function() {
        var liHtml = "<li>" + $(this).attr("ows_My Question / Ma questions") + $(this).attr("ows_Answer") + "</li>";
        $("#tasksUL").append(liHtml);
      });
    }
  });
});

So I'm having issues with the space and / characters for this column name. I know the

listName: "Question Archive / Archive des questions",

and other code works because, the ows_Answer shows up. I've tried changing the spaces and forwardslash to different variations of unicode and javascript character code, but that column just doesn't show up. It returns an "undefined" value.

$(this).attr("ows_My_x0020_Question_x0020__x002f__x0020_Ma_x0020_questions")

didn't work. Unfortunately, I cannot change the column name.

  • What is the internal name of your list? – Kaushal Khamar Mar 28 '16 at 7:22
2

You can use list settings page to find the field internal name and use that in the query.

Open list settings and click on the column hyperlink which takes you to the column settings page. Just look for query string Field.

  • Thanks Amal, I tried the method you advise and it indeed shows: "My%5Fx0020%5Fquestion%5Fx0020%5F%5Fx002f%5F%5F" But I tried to use that in my code and it still comes up as undefined. I used it for both: <FieldRef Name="My%5Fx0020%5Fquestion%5Fx0020%5F%5Fx002f%5F%5F" /> $(this).attr("ows_My%5Fx0020%5Fquestion%5Fx0020%5F%5Fx002f%5F%5F") But it still doesn't show up. – Chester Mar 28 '16 at 4:20
  • Thanks, I tried yesterday but I guess I don't have enough points to accept more than 1 answer per day. I just checked it. – Chester Mar 30 '16 at 17:53
0

I figured it out, thanks to Amal and Anatoly (from this thread).

I went into the settings like Amal suggested and found the name in the URL. My%5Fx0020%5Fquestion%5Fx0020%5F%5Fx002f%5F%5F which I guess SharePoint has a character limit because the full name is My question / Ma question. Anyways, I used that for the . Then using Anatoly's suggestion I used the underscore for the "ows_". Here is my full code:

 $().SPServices({
operation: "GetListItems",
async: false,
listName: "Question Archive / Archive des questions",
CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='My%5Fx0020%5Fquestion%5Fx0020%5F%5Fx002f%5F%5F' /><FieldRef Name='Answer' /></ViewFields>",
completefunc: function (xData, Status) {
  $(xData.responseXML).find("z\\:row, row").each(function() {
    var liHtml = "<li>" + $(this).attr("ows_Title") + " " + $(this).attr("ows_My_x0020_question_x0020__x002f__") + $(this).attr("ows_Answer") + "</li>";
    $("#tasksUL").append(liHtml);
  });
}
});

As you can see, space is %5Fx0020%5F for the FieldRef Name, but I replaced the %5F with underscore for the "ows_" so the space becomes x0020

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.