Using Custom HTML Resource on a view to disable Alerting for a group of Applications


Because my internal customers demanding it heavily I've created a little JavaScript for use with an Custom HTML Resource to enable or disable alerts for a group of items. It creates two links (Mute Alerts, Unmute Alerts) feel free to change that to something like two buttons. It could be put on every View and will work as long as the user logged in has the right to mute the alerts on the group of objects. 

Be aware that you will use it at your own risk!

It shows two links, one to enable and one to disable the muting. Please be aware that you might change the language part in the java script includes for your needs and also the version part might be changed after an update.

<script type="text/javascript" src="/orion/js/[scriptname]?l=en-US&v=44040.43.L"></script>

Beside that you need of course to change the search for your needs

 var swql="select a.Uri as URI From Orion.APM.Application a where a.ApplicationTemplateID = 4711 and a.Name like '%whatever%'";

 And the paragraph name to be unique on the page:

<p id='mute_whatever_group'></p>

Here is the script:

<p id='mute_whatever_group'></p>
<script type='text/javascript' src=''></script>
<script type="text/javascript" src="/orion/js/stringutils.js.i18n.ashx?l=en-US&v=44040.43.L"></script>
<script type="text/javascript" src="/orion/js/progressdialog.js.i18n.ashx?l=en-US&v=44040.43.L"></script>
<script type="text/javascript" src="/orion/js/maintenancemode/alertsuppressionhandlers.js.i18n.ashx?l=en-US&v=44040.43.L"></script>
<script type="text/javascript" src="/orion/js/maintenancemode/alertsuppressionstatusdescription.js.i18n.ashx?l=en-US&v=44040.43.L"></script>
<script type="text/javascript" src="/orion/js/maintenancemode/maintenancemodeutils.js.i18n.ashx?l=en-US&v=44040.43.L"></script>

        var swql="select a.Uri as URI From Orion.APM.Application a where a.ApplicationTemplateID = 4711 and a.Name like '%whatever%'";
        var params = JSON.stringify({
            query: swql,
            parameters: {}                                         
            type: 'POST',
            url: '/Orion/Services/Information.asmx/QueryWithParameters',
            data: params,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(response) {
                var i;
                var output = "<a id='ScheduleAlertSuppression' href='javascript&colon;;' onclick=\"return SW.Core.MaintenanceMode.ScheduleAlertSuppression([";
                var uris = ''
                for(var i=0; i < response.d.Rows.length; i++){
                    uris = uris.concat("'")
                    uris = uris.concat([response.d.Rows[i][0]])
                    uris = uris.concat("',") 
                output = output.concat(uris)
                output = output.concat("])\">Mute Alerts</a>");
                output = output.concat("&nbsp;&nbsp;<a id='ResumeAlerts' href='javascript&colon;;' onclick=\"return SW.Core.MaintenanceMode.ResumeAlerts([");
                output = output.concat(uris)
                output = output.concat("])\">Unmute Alerts</a>");
                document.getElementById("mute_whatever_group").innerHTML = output;