Alerts.DeleteAlerts() for users other than current user?

Nov 8, 2012 at 12:00 PM

Hi,

I am trying to use DeleteAlerts() to delete all alerts from some lists but I get

'{alertId}ServerError', for any alert which is not my own.

 

I am using this code

$().SPServices({
  operation: 'DeleteAlerts',
  webURL: 'https://' + window.location.host + L_Menu_BaseUrl;
  async: false,  
  IDs: ids,
  completefunc: function(xData, Status) {
    var delErr = $(xData.responseXML).find('DeleteFailure').text();
    if (!!delErr[0] && typeof console == 'object'){
      console.log(delErr);
    }
  }
});	

On the msdn page I see nothing about the method being only available to the current user. I have full control over my subsite, and SPServices webURL is set to that.

 

Anyone knows if I can delete other users alerts using Web Services?

 

Thank you,

vinz

 

Coordinator
Nov 8, 2012 at 2:02 PM

Vinz:

Have you tried passing in one id at a time? I'm not exactly sure what the delimiter ought to be for multiple ids; one at a time probably will work. Just add an outer loop to iterate through your array of ids.

M.

Nov 8, 2012 at 3:23 PM

Hi Marc,

Thank you for your reply.

I have just tried that

 

$().SPServices({
  operation: 'DeleteAlerts',
  webURL: 'https://' + window.location.host + L_Menu_BaseUrl,
  async: false,  
  IDs: ['{1C364549-0080-4200-B9B1-57C80DB401FD}'],
  completefunc: function(xData, Status) {
    var delErr = $(xData.responseXML).find('DeleteFailure').text();
    if (!!delErr[0] && typeof console == 'object'){
      console.log(delErr);
    }
  }
});

 

Response:

 

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
   <DeleteAlertsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/">
    <DeleteAlertsResult>
     <DeleteFailure>
       <ID>{1C364549-0080-4200-B9B1-57C80DB401FD}</ID>
       <Error>ServerError</Error>
     </DeleteFailure>
    </DeleteAlertsResult>
   </DeleteAlertsResponse>
  </soap:Body>
</soap:Envelope>

 

If I run the same code with one of my alerts I get this Response

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Body>
    <DeleteAlertsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/">
     <DeleteAlertsResult></DeleteAlertsResult>
    </DeleteAlertsResponse>
  </soap:Body>
</soap:Envelope>

 

 

It also works with multiple Ids (my alerts), in the form

['{id GUID 1}','{id GUID 2}','{id GUID 3}']

 

Does it mean that DeleteAlerts is only set on the current user?

This would make the Web Service pretty useless. And with only /_layouts/sitesubs.aspx left for managing alerts - for one user at a time - managing alerts on Sharepoint proves incredibly time consuming, and very, very boring and frustrating.
Should I just surrender to it?
Thank you,
vinz
Coordinator
Nov 21, 2012 at 3:49 AM

vinz:

I haven't had time to look at this, but I wouldn't be too surprised if your findings are valid. Some of these Web Services are written very strangely.

M.

Nov 23, 2012 at 8:34 PM

Hi Marc,

Thank you for your reply. you must be crazy busy I am actually impressed you find the time to reply to queries at all.

That being said, if even you think my findings may be right, I give up! :)

I'll resort looping though users via iframe pointed to /_layouts/sitesubs.aspx and that is that. Not elegant, but hey.

 

Thank you!

vinz