AutoActionEdit
From TDiWiki
This script is designed to edit all of the Automatic Actions that have certain characteristics. It can be very useful for example after migrating your ConsoleWorks invocation from one platform to another when you must change the type of external script being used. In this example we are changing the VMS script "MAIL" to a Windows BAT file "MAIL.BAT."
[edit] Script Properties
Name: AUOTACTIONEDIT
Description: Edit the external script setting for an Automatic Action.
Profile: CONSOLE_MANAGER
Timeout: 30 (seconds)
[edit] Run Type
Run on Events
Run on Scans
[edit] Script Text
// * Copyright 1999-2011 TDi Technologies, Inc. All rights reserved. *
// * The information in this software is subject to change without *
// * notice and should not be construed as a commitment by TDi. *
// * Created: 10/18/2011 *
var events = new Array();
if(action.Event) {
// Get specific Event(s)
events[0]=Event.get(action.Event);
log("CONWRKS","Got Event: "+events[0].name);
} else if (action.Scan) {
// Get list of Events in Scan
var scn = Scan.get(action.Scan);
log("CONWRKS","Querying Event List for Scan: "+scn.name);
events = scn.getEvents();
log("CONWRKS","Got Event List");
} else {
// Get list of all Events
log("CONWRKS","Querying Event List");
events = Event.getList();
log("CONWRKS","Got Event List");
}
if(events&&events.length>0) {
var numevt = 0;
for (var x=0;x<events.length;x++) { // Loop through targeted Events (either a specific event or all events)
// get the automatic action
var acts=events[x].getEventToAutomaticAction();
if(acts&&acts.length>0) { // if the automatic action exists and is not emply
for(var i=0;i<acts.length;i++) {
if(acts[i].action=="MAIL") { // if the external script is MAIL, set it to MAIL.BAT
acts[i].action="MAIL.BAT";
if(acts[i].save()) { // save the automatic action
log("CONWRKS","changing mail script to bat");
numevt++
} else {
log("CONWRKS","failed changing mail script to bat");
}
}
}
}
}
log("CONWRKS",numevt+" Events were updated.");
} else {
log("CONWRKS","Failed to get the event(s)");
}
