May 05, 2014

REST - Web Services - CSOM - SharePoint 2013

REST

var query =


"/_api/web/lists/getbytitle('Employee')/items?$select=Title,Company,Manager&
$filter= ID eq '" + qryID + "'";


$.ajax({

url: _spPageContextInfo.webAbsoluteUrl + query,
 
type: "GET",

headers: { "ACCEPT": "application/json;odata=verbose" },

success: function (data) {

$.each(data.d.results, function (idx, item) {

console.log(item.Title); //Employee Title

console.log(item.Company.Title); //Company Title

console.log(item.Manager.Title); //Manager Title

});

},
 
 
error: function (data) {

}

});
 

Web Services

var listName = "myList";

$(document).ready(function() {
    var soapEnv =
        "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'> \
             <soapenv:Body> \
                  <GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'> \
                     <listName>"+listName+"</listName> \
                     <viewFields> \
                         <ViewFields> \
                            <FieldRef Name='Title' /> \
                        </ViewFields> \
                     </viewFields> \
                 </GetListItems> \
             </soapenv:Body> \
         </soapenv:Envelope>";

   
    $.ajax({
        url: asmx(),
        type: "POST",
        dataType: "xml",
        data: soapEnv,
        complete: processResult,
        contentType: "text/xml; charset=\"utf-8\""
    });
});

function asmx() {

    var url = window.location.href;
    var urlin = url.substring(7);
    var urlsplit = urlin.split("/");
    var dolzina = urlsplit.length - 1;
    var naslov = new Array();
    for(i = 0; i < dolzina; i++){
        var naslov = naslov + urlsplit[i] + "/";
    }
    var asmx =  "http://" + naslov + "_vti_bin/lists.asmx";
    return asmx;

}

function processResult(xData, status) {
    $(xData.responseXML).find("z\\:row").each(function() {
        var liHtml = "
  • "
  • + $(this).attr("ows_Title") + " - " + $(this).attr("ows_Total") + "
    ";
            $("#data").append(liHtml);
        });
    }

    JavaScript Object Model (JSOM)

    <script type="text/ecmascript">
     
        SP.SOD.executeOrDelayUntilScriptLoaded(initialize, 'SP.js');   
        function initialize() {
            var clientContext = new SP.ClientContext();
            var siteColl = clientContext.get_site();
            myweb = siteColl.get_rootWeb();
            this.list = myweb.get_lists().getByTitle('ListTitle'); //Edit the title
            clientContext.load(list);
            clientContext.executeQueryAsync(Function.createDelegate(this, GetList), Function.createDelegate(this, getFailed));
        }
        function GetList() {
                alert(list.get_title() + ': ' + list.get_id().toString());
        }
      
        function getFailed() {
            alert('Failed.');
        }
    </script>

    SonarQube with Jenkins Setup using Docker Images

    https://funnelgarden.com/sonarqube-jenkins-docker/  https://medium.com/@hakdogan/an-end-to-end-tutorial-to-continuous-integration-and-con...