This project has moved and is read-only. For the latest updates, please go here.

Can't seem to get the GetAlerts webservice to work in a demo...

Aug 21, 2012 at 1:17 PM

Hi Marc,

 I'm loving the library - this is an awesome piece of kit to use in Sharepoint! I do have a question though, about how to get the GetAlerts web service to work in a demo:

<script src="" type="text/javascript"></script>  
<script type="text/javascript" src=""></script>  

<script type="text/javascript">
var divId = "#WSOutput";
var out = "";

// main function
$().ready(function () {
var theList =  "";
    operation: "GetAlerts",
    async: false,
    webUrl: "<server url>",    //name removed for post
    completefunc: function (xData, Status) {
       $(divId).append("<b>This is the output from the GetAlerts operation:</b><br>");
        var out = $().SPServices.SPDebugXMLHttpResult({
	  node: xData.responseXML,
	  outputId: divId

	$(xData.responseXML).find("Alerts > Alert").each(function() {
	  var exist = $(this).attr("Id");
	  if (exist == "" ){
	    alert("No alerts for this site");
	  } else {
            theList = $(this).attr("Title");
	    var theURL = $(this).attr("AlertForUrl");
            var theGUID = $(this).attr("Id");
	    var Row = "Title: " + theList +" - " + theURL + " - " + theGUID;
	}); //each           



<div id="WSOutput"></div>

 I'm struggling to see what I'm doing wrong on this - every time I use the above demo, I get back the SOAP response to indicate there is an alert set on the site (which is the case), but when trying to get back inidividual responses, all I get back is "undefined". The above code is a variation from, allowing for any comments made after the original post.

I've tried changing the location of the variables that are defined, to ensure this is not simply down to not declaring them at the right time; it hasn't made any difference. Could some please point me in the right direction?



Sep 11, 2012 at 1:50 PM


It may be that you are using "Id" rather than "ID". Capitalization matters!

Sorry for the delayed response, but I was on holiday.


Sep 12, 2012 at 8:41 AM

Hi Marc,

No problem - we all have to have a break sometimes... ;-)

Thanks for this - I managed to trace where I went wrong; I wasn't using the right methods to filter out the right nodes in the XML being returned. Here's a sample for anyone who needs it:

        $(xData.responseXML).SPFilterNode("Alerts").each(function() {
	  $(this).find("Alert").each(function() {
            var alertID = $(this).find("Id").text();
            var alertTitle = $(this).find("Title").text();
            var alertActive = $(this).find("Active").text();
            var alertEventType = $(this).find("EventType").text();
            var alertForUrl = $(this).find("AlertForUrl").text();
            var alertEditUrl = $(this).find("EditAlertUrl").text();

            out += "Alert ID: " + alertID + "<br>" +
                   "Alert Title: " + alertTitle + "<br>" +
                   "Active: " + alertActive + "<br>" + 
                   "Event Type: " + alertEventType + "<br>" +
                   "Root Url: " + alertForUrl + "<br>" +
                   "Alert Edit Url: " + alertEditUrl + "<br>" +

It's working beautifully now - I guess it's all part of the learning curve, as I am still somewhat new to traversing XML using jQuery! I am really loving the library though - it's an awesome bit of kit!