1

I am looking for a solution to get past the search query option through SharePoint Online.

We have a department that uses a subsite template to put in new orders. Within this template there is a list. One of the fields we want to call is the "Status" field.

We are working on creating a dashboard that calls these lists within a site collection looking for this specific "Status" field value.

Can anyone get me started on some coding, whether it be Javascript, CAML, etc. to put into a script editor webpart to show the lists that meet specific "Status" values?

Many thanks in advance!

1 Answer 1

0

You could try below code shared by Md. Tahmidul Abedin

function restCallwithCaml(listName, caml) {
             /// get the site url
             var siteUrl = _spPageContextInfo.siteAbsoluteUrl;
             /// set request data     
             var data = { "query" : {"__metadata": 
             { "type": "SP.CamlQuery" }, "ViewXml":caml}};
             /// make an ajax call
             $.ajax({
                url: siteUrl+"/_api/web/lists/GetByTitle
                ('"+ listName +"')/GetItems",
                method: "POST",
                data: data,
                headers: {
                   "X-RequestDigest": $("#__REQUESTDIGEST").val(),
                   'content-type': 'application/json;odata=verbose',
                   'accept': 'application/json;odata=verbose'
                }
                success: function (response) {
                    ///do your code
                },
                error: function (data) {
                  ///do your code
                }
            });
       }

https://www.codeproject.com/Tips/1181172/SharePoint-REST-API-CAML-Query

Update:

Sample caml for choice field:

<Where>   
<Eq>    
<FieldRef Name='yourField'/><Value Type='Choice'>value</Value>    
</Eq>    
</Where>
1
  • Thanks! This seems close, but it looks like it searches by List title? I am after a query that looks for all lists on a collection, narrowed down by the "Status" field...
    – jaredjohn
    Commented Dec 13, 2017 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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