Function

$().SPServices

Web Service

Alerts

Supported Operations

Operation Options MSDN Documentation Introduced
GetAlerts [webURL] Alerts.GetAlerts Method 0.2.8
DeleteAlerts [webURL], IDs Alerts.DeleteAlerts Method 0.2.8

Last edited Sep 14, 2009 at 8:22 PM by sympmarc, version 3

Comments

bobbybeckner Mar 27, 2012 at 8:37 PM 
//I created some custom code to add alerts via an iframe and a timeout with callback. I figured it might //be useful for someone else. Here it is.

alerts = {
subscribe : function(title, webUrl, listName, users, changeMethod, changeType, callback){
var url = "/_layouts/SubNew.aspx?List={0}";
$('#iframe').remove();
bb.lists.getList(listName, function(list){
url = String.format(url, list.ID);
var $iframe = $(String.format("<iframe id='iframe' src='{0}'></iframe", url));
// var $iframe = $(String.format("<iframe id='iframe' src='{0}' style='position: absolute; top: -1000px; left: -1000px'></iframe", url));
$(document).find('.ms-bodyareaframe').append($iframe);
window.setTimeout(function(){
var $i = $("#iframe").contents();
$i.find('#ctl00_PlaceHolderMain_ctl02_ctl00_TextTitle').val(title);
$i.find('#ctl00_PlaceHolderMain_ctl03_ctl00_userPicker_downlevelTextBox').val('');

for(var i = 0; i < users.length; i++){
$i.find('#ctl00_PlaceHolderMain_ctl03_ctl00_userPicker_downlevelTextBox').val(
$i.find('#ctl00_PlaceHolderMain_ctl03_ctl00_userPicker_downlevelTextBox').val() +
users[i] + ";"
)
}

//Update "Only send me alerts when" with Change Method
$i.find('#ctl00_PlaceHolderMain_ctl05_ctl00_RadioBtnEventType_' + changeMethod).attr('checked', 'checked')

//Update "Send me an alert when" with Change Type
$i.find('#ctl00_PlaceHolderMain_ctl06_ctl01_RadioBtnAlertFilter_' + changeType).attr('checked', 'checked')

$i.find('#ctl00_PlaceHolderMain_ctl01_RptControls_BtnCreateAlert').click()

window.setTimeout(function(){
$('#iframe').remove();
callback(true);
}, 1000);

}, 500);
})
}
}