// This file is called from ChooseServerGroupMembers.csp.
// Depending on the button clicked:
// A server is added or removed from the selected server group.
// A group associate is added or deleted from the server group.
<!-- #include file="RetrieveIStore.csp" -->
<!-- #include file=helper_js.csp -->
function AddServerGroupMember(IStore, ServerGroupId, ServerName)
// This function adds a server to a server group.
// IStore - The InfoStore object.
// ServerGroupId - The InfoObject ID of the selected ServerGroup object.
// ServerName - The InfoObject Title of the selected Server object.
// Query for the selected server group.
var ServerGroups = IStore.Query
("SELECT SI_GROUP_MEMBERS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);
// Get the ServerGroup object.
ServerGroup = ServerGroups.Item(1).PluginInterface("");
// Add the server. Note you are handing it the Server InfoObject's Title.
ServerGroup.Servers.Add(ServerName);
// Save the changes to the APS.
function DeleteServerGroupMember(IStore, ServerGroupId, MemberName)
// This function deletes a server from a server group.
// IStore - The InfoStore object.
// ServerGroupId - The InfoObject ID of the selected ServerGroup object.
// MemberName - The InfoObject Title of the selected Server object.
// Query for the selected server group.
var ServerGroups = IStore.Query
("SELECT SI_GROUP_MEMBERS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);
// Get the ServerGroup object.
ServerGroup = ServerGroups.Item(1).PluginInterface("");
// Delete the selected server by passing the Server InfoObject's Title.
ServerGroup.Servers.Delete(MemberName);
// Save the changes to the APS.
function ClearServers(IStore, ServerGroupId)
// This function deletes all servers from a server group.
// IStore - The InfoStore object.
// ServerGroupId - The InfoObject ID of the selected ServerGroup object.
// Query for the selected server group.
var ServerGroups = IStore.Query
("SELECT SI_GROUP_MEMBERS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);
// Get the ServerGroup object.
ServerGroup = ServerGroups.Item(1).PluginInterface("");
// Clear all servers from the group.
// Save the changes to the APS.
function AddGroupAssociate(IStore,ServerGroupId, GroupID)
// This function adds a server group associate to a server group.
// IStore - The InfoStore object.
// ServerGroupId - The InfoObject ID of the selected ServerGroup object.
// This is the main server group.
// GroupID - The InfoObject ID of the selected ServerGroup object.
// This is the group associate.
// Query for the selected server group.
var ServerGroups = IStore.Query
("SELECT SI_SUBGROUPS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);
// Get the ServerGroup object.
ServerGroup = ServerGroups.Item(1).PluginInterface("");
// Add the server group associate.
// The ID of the server group is added to the collection.
ServerGroup.SubGroups.Add(GroupID);
// Save the changes to the APS.
function DeleteGroupAssociate(IStore, ServerGroupId, GroupID)
// This function deletes a server group associate from a server group.
// IStore - The InfoStore object.
// ServerGroupId - The InfoObject ID of the selected ServerGroup object.
// This is the main server group.
// GroupID - The InfoObject ID of the selected ServerGroup object.
// This is the group associate.
// Query for the selected server group.
var ServerGroups = IStore.Query
("SELECT SI_SUBGROUPS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);
// Get the ServerGroup object.
ServerGroup = ServerGroups.Item(1).PluginInterface("");
// Concatenate # with the ID and give it to the
// Delete method. If you give it just the ID, it will
// treat it as an array index and remove the wrong server.
ServerGroup.SubGroups.Delete("#" + GroupID);
// Save the changes to the APS.
function ClearGroups(IStore, ServerGroupId)
// This function deletes all associates from the group.
// IStore - The InfoStore object.
// ServerGroupId - The InfoObject ID of the selected ServerGroup object.
// Query for the selected server group.
var ServerGroups = IStore.Query
("SELECT SI_SUBGROUPS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+ServerGroupId);
// Get the ServerGroup object.
ServerGroup = ServerGroups.Item(1).PluginInterface("");
// Clear all group associates from the group.
ServerGroup.SubGroups.Clear();
// Save the changes to the APS.
Response.Redirect ("Start.csp");
ServerGroupId = String(Request.QueryString.Item("ServerGroupId"));
// Depending on what the user selected in ChooseServerGroupMembers.csp:
// - Add or remove the server from the group.
// - Add or remove the group associate from the group.
if (Request.Form.Item("AddServer") == "Add a server")
ServerName = String(Request.Form.Item("ServerName"));
AddServerGroupMember(IStore,ServerGroupId, ServerName);
Response.Redirect ("ChooseServerGroupMembers.csp
if (Request.Form.Item("RemoveServer") == "Remove a server")
MemberName = String(Request.Form.Item("MemberName"));
DeleteServerGroupMember(IStore,ServerGroupId, MemberName);
Response.Redirect ("ChooseServerGroupMembers.csp
if (Request.Form.Item("ClearServers") == "Clear all servers")
ClearServers(IStore,ServerGroupId);
Response.Redirect ("ChooseServerGroupMembers.csp
if (Request.Form.Item("AddGroup") == "Add a group")
GroupID = Number(Request.Form.Item("GroupID"));
Response.Write("GROUPID: " + GroupID + "<BR>")
AddGroupAssociate(IStore,ServerGroupId, GroupID);
Response.Redirect ("ChooseServerGroupMembers.csp
if (Request.Form.Item("RemoveGroup") == "Remove a group")
SubGroupID = String(Request.Form.Item("SubGroupID"));
Response.Write("GROUPID" + SubGroupID + "<BR>")
DeleteGroupAssociate(IStore,ServerGroupId, SubGroupID);
Response.Redirect ("ChooseServerGroupMembers.csp
if (Request.Form.Item("ClearGroups") == "Clear all groups")
ClearGroups(IStore,ServerGroupId);
Response.Redirect ("ChooseServerGroupMembers.csp
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |