Jump to content


choyrack

Email allert when ADR add new updates to group

Recommended Posts

Hello

 

Is it possible in SCCM 2012 to set alert which will be triggered when ADR add new updates to Updates Group?
If SCCM does not allow to do that, maybe it is possible by job in SQL server (for example checking for changes in some table or something like that?)

 

Regards

Mariusz

Share this post


Link to post
Share on other sites

Hello

 

My solution below.

 

USE [CM_E12]
GO
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[_EUR_LastChanges_In_SMSPackages_G](
[PkgID] [nvarchar](8) NOT NULL,
[LastRefresh] [datetime] NULL,
CONSTRAINT [PK__EUR_1] PRIMARY KEY CLUSTERED
(
[PkgID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

 

 

USE [CM_E12]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[_EUR_SendMailOnLastChanges]
ON [dbo].[sMSPackages_G]
AFTER UPDATE, INSERT
AS
BEGIN
SET NOCOUNT ON;

IF UPDATE (LastRefresh)
BEGIN
IF (SELECT LastRefresh FROM [dbo].[_EUR_LastChanges_In_SMSPackages_G] WHERE PkgID = (SELECT PkgID FROM inserted)) IS NULL
BEGIN
INSERT INTO [CM_E12].[dbo].[_EUR_LastChanges_In_SMSPackages_G]
([PkgID]
,[LastRefresh])
VALUES
((SELECT PkgID FROM inserted)
,(SELECT LastRefresh FROM inserted))
END

IF ((SELECT LastRefresh FROM [dbo].[_EUR_LastChanges_In_SMSPackages_G] WHERE PkgID = (SELECT PkgID FROM inserted)) <> (SELECT LastRefresh FROM inserted))
BEGIN
DECLARE @body NVARCHAR(MAX);
SET @body = '<html><body>'
SET @body += 'Grupa: ' + RTRIM((SELECT Name FROM inserted)) + ' (' + RTRIM((SELECT PkgID FROM inserted)) + ')'
SET @body += '<br>Godzina dodania: ' + RTRIM((SELECT LastRefresh FROM inserted))
SET @body += '</body></html>'

EXEC msdb.dbo.sp_send_dbmail
@recipients = 'yyy@xxx.pl',
@profile_name = 'SCCM_Mail',
@subject = 'SCCM | Nowe aktualizacje',
@body = @body,
@body_format = 'HTML'
END
END

UPDATE [dbo].[_EUR_LastChanges_In_SMSPackages_G]
SET LastRefresh = (SELECT LastRefresh FROM inserted)
WHERE PkgID = (SELECT PkgID FROM inserted)
END

Share this post


Link to post
Share on other sites

This is so not supported and will likely cause problem the next time you try to upgrade you site.

 

Why wouldn't you take an (IMO) easier and support method and setup Status filter rule to execute a SSRS report or something like that?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.