0

Is there a way to get the ID from the SPGetCurrentSite? I want to use in my Where clause for my CAML Statement/ID field in the SharePoint list item. I'm new to CAML and I was using the below but I'm not getting the individual list item (getting the whole list).

  var urlParam = GetUrlKeyValue("ID");  
    <Query><OrderBy><FieldRef Name='ID' Ascending='True' /><Where><Eq>" + urlParam + "</Eq></Where></OrderBy></Query>";
  • Can you mention what you are looking for ID from url or current site or current web id – Sunil Sahu Nov 7 '19 at 6:43
  • It would the current site. In other words, I would like to pull X from the ID=X querystring in the address bar and use it as the Where clause value for ID. So when I click on an item in the List View, it will take me to the Display Page, take the ID from the URL in the address bar and use it to filter only that Item in the Display page. – adams-j Nov 7 '19 at 13:18
0

I figured it out. My CAML Query Statement was all wrong. From above the above:

 <Query><OrderBy><FieldRef Name='ID' Ascending='True' /><Where><Eq>" + urlParam + "</Eq></Where></OrderBy></Query>";

To

"<Query><Where><Eq><FieldRef Name='ID'/><Value Type='Number'>" + urlParam + "</Value></Eq></Where></Query>";
| improve this answer | |

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.