0

How would I display the result of a CAML query via javascript on a SharePoint page? I'm trying to use this result in inline HTML similar to this:

<h5> Current OnCall: [CAML Result]</h5>
  • 1
    What exactly do you mean by the result of a CAML query via javascript. Are you trying to fetch data from SharePoint list and you want to show that on SharePoint page ? can you elaborate it more.... – Rohit Waghela Jun 14 '17 at 18:33
  • i have a CAML query that pulls the current on call person from a list. I need to display this persons name on a SharePoint page. I was thinking the best way may be to use JS and a variable, but i was having a tough time getting it to work so I thought I would throw out the question for assistance. – Josh Henderson Jun 15 '17 at 12:05
0

You may put the entire CAML Query result in a variable, then you can add it to the DOM as such:

HTML:

<h5 id="camltext"></h5>

JavaScript:

var camlResult = JSON.stringify(data.d.results); //find CAMLResults from JSOM
var textnode = document.createTextNode(camlResult );
document.getElementById('camltext').appendChild(textnode);
  • Thank you for your answer this looks like it's pointing me in the right direction. Do I add the CAML query? – Josh Henderson Jun 15 '17 at 19:23

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.