caml query join using SP Services and JQuery

Oct 24, 2014 at 7:48 PM
I'm stuck on something big, I have 2 lists that I have to query and show the items from each list. My lists look like

Topic:
title, id, author

Comments
Title, id, topic_id,

I need to query both and show
topic.title, and comments.title

I've looked at several examples online and none really help. How can I create a way to query both lists and show the values on my page?
Coordinator
Oct 24, 2014 at 7:52 PM
You can just use GetListItems or GetListItemsJson to query each list and display the content. You haven't said how the two lists are related, but if they are and the values for topic.title, and comments.title need to match somehow, you'll do that in your script.

M.
Oct 27, 2014 at 11:43 AM
They're connected by the Topic.ID and the Comments.Topic_ID

do you have an example? Most of everything I found online didn't work
Coordinator
Oct 27, 2014 at 1:14 PM
Well, you're probably not going to find an example that's exactly what you want to do. You should query each list and load the data into arrays. Then you would look up the topic based on the ID as you display each comment.

M.
Oct 27, 2014 at 1:21 PM
Way I see it, you query both lists and save the result for each in an array.
var topicsArr = [{title:title1,id:1},{title:title2,id:2}]
var commentsArr = [{id:1,comment:"words"},{id:2,comment:"words2"}]
From there you just need to figure out how to merge the two and work with 1 object or call the results of both using the ID.

Lodash might help here to work with the arrays.

This is more of a javascript data manipulation issue though, you'll get a faster answer at Stackoverflow. or Goolge provides some existing results