AnsweredAssumed Answered

Translating AJAX POST to Office 365 Web Request

Question asked by patrickabel Champion on Oct 31, 2016
Latest reply on Oct 31, 2016 by fhunth

Using a client-side AJAX call, I am currently using a SharePoint SOAP web-service to return and expand recurring calendar events (../_vti_bin/Lists.asmx?op=GetListItems). I'm looking to port this logic to a Nintex workflow Web Request action so that I can iterate these recurring event instances within a collection.

 

Here's a sample of the JavaScript function:

// Function to fetch events (expanding recurring ones)
function testSOAPWebService() {
    webServiceURL = _spPageContextInfo.webAbsoluteUrl + "/_vti_bin/Lists.asmx";
    var soapXML = "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>" +
        "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" +
        "<listName>03C1CB74-CC2F-4565-BED5-0616C4A770EA</listName>" +
        "<query>" +
        "<Query>" +
        "<Where>" +
        "<DateRangesOverlap>" +
        "<FieldRef Name=\"EventDate\" />" +
        "<FieldRef Name=\"EndDate\" />" +
        "<FieldRef Name=\"RecurrenceID\" />" +
        "<Value Type='DateTime'><Year/></Value>" +
        "</DateRangesOverlap>" +
        "</Where>" +
        "</Query>" +
        "</query>" +
        "<queryOptions>" +
        "<QueryOptions>" +
            "<ExpandRecurrence>TRUE</ExpandRecurrence>" +
        "</QueryOptions>" +
        "</queryOptions>" +
        "</GetListItems>" +
        "</soap:Body></soap:Envelope>";
    var result = [];
    $.ajax({
        url: webServiceURL,
        type: "POST",
        dataType: "xml",
        async: false,
        data: soapXML,
        contentType: "text/xml; charset=\"utf-8\"",
        complete: function (xData, status) {
            console.log("URL: " + webServiceURL + " Status: " + status);
            if (status === "success") {
                var root = $(xData.responseText);
                root.find("listitems").children().children().each(function () {
                    $this = $(this);
                    var ids = $this.attr("ows_UniqueId").split(";");
                    var rec = $this.attr("ows_fRecurrence");
                    result.push({
                        "StartTime": $this.attr("ows_EventDate"),
                        "EndTime": $this.attr("ows_EndDate"),
                        "Title": $this.attr("ows_Title"),
                        "Recurrence": (rec === "1" ? true : false),
                        "Description": $this.attr("ows_Description"),
                        "Guid": ids[1],
                        "Id": ids[0],
                    });
                });
            }
        }
    });
    console.log(result);
}

 

Although I've recently had some success making some simple SOAP web-service calls in Nintex workflow, I can't manage to get any results back in the response XML in this case. Here's what I'm doing at the moment:

 

Anyone have any O365 samples doing something similar with complex CAML queries?

Vadim Tabakman Sean Fiene

Outcomes