so I tried the AddEvent SP out. It works fine.
However I read somewhere that this undocumented procedure might be a deprecated feature of SQL Server. (still available in my SQL Server 2012 SSRS)
So you should not get too attached to it.
meanwhile...
I would like to use this e.g. in my SQL Agent Jobs.
For this I need to mimimze my maintenance task, as I am not always around when someone is modifing the cache configurations (e.g. deleting one cache config and creating a new one), I don't know if the EventData-IDs might have changed.
So I created a little procedure that fetches all the subscriptions of an desired type (e.g. RefreshCache) and creates an AddEvent-Call for it.
I kept it simple, but feel free to put more effort into it. You can probably filter subscriptions that are still active and so on...
As it is encapsulated there is a change to modify what is triggered one's M$ replaces the AddEvent-Procedure with something new.
Have fun
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:Christian Terhart
-- Create date: 2013-02-18
-- Description:Trigger Report Scheduled Task
-- =============================================
ALTER PROCEDURE dbo.usp_report_event_trigger
@report_name nvarchar(425) = NULL,
@report_path nvarchar(425) = '',
@report_action int = -1
/*ReportActionEventType
3CacheInvalidateSchedule
4TimedSubscription
5RefreshCache
*/
AS
BEGIN
SET NOCOUNT ON;
DECLARE @exec_command nvarchar(4000) = '';
SELECT
@exec_command =
@exec_command + N'EXECUTE ReportServer.dbo.AddEvent @EventType=''' + sc.EventType + ''', @EventData='''+CONVERT(nvarchar(36), UPPER(rs.SubscriptionID))+N'''; '
FROM dbo.Catalog AS c
INNER JOIN dbo.ReportScheduleAS rs ON (c.ItemID = rs.ReportID AND rs.SubscriptionID IS NOT NULL)
INNER JOIN dbo.ScheduleAS sc ON (rs.ScheduleID = sc.ScheduleID)
WHERE c.Name = @report_name
AND (c.Path = @report_path OR @report_path = '')
AND (rs.ReportAction = @report_action OR @report_action = -1)
EXECUTE sp_executesql @exec_command
END
GO