<!-- #include file="RetrieveIStore.csp" -->
function AddUserToNewGroup(IStore, UserID, NewGroupName)
// Retrieve the Plugin Manager.
var PluginMgr = IStore.PluginManager;
// Retrieve the UserGroup interface.
var UserPlugin = PluginMgr.PluginInfo("CrystalEnterprise.UserGroup");
// Create a new InfoObjects collection.
var NewInfoObjects = IStore.NewInfoObjectCollection();
// Add the UserGroup interface to the new InfoObjects collection.
NewInfoObjects.Add (UserPlugin);
// Get the new UserGroup object.
var NewUser = NewInfoObjects.Item(1);
// Set the UserGroup properties.
// Add a User to the new UserGroup.
NewUser.PluginInterface("").Users.Add(Number(UserID));
// Commit the changes to the APS.
IStore.Commit (NewInfoObjects);
function RemoveUserFromGroup(IStore, UserID, GroupID)
Response.Write("Removing user with ID " + UserID + " from group with ID " + GroupID + "<BR>");
// Retrieve the User you wish to remove from the group.
var Result = IStore.Query("SELECT SI_ID, SI_USERGROUPS FROM CI_SYSTEMOBJECTS WHERE SI_ID="+UserID);
// Retrieve the Groups collection.
var MemberGroups = User.PluginInterface("").Groups;
// Delete the Group from the collection.
MemberGroups.Delete("#"+GroupID);
function AddUserToGroup(IStore, UserID, GroupID)
Response.Write("Adding user with ID " + UserID + " to group with ID " + GroupID);
// Retrieve the User object you want to add the Group to.
var Result = IStore.Query("SELECT SI_ID FROM CI_SYSTEMOBJECTS WHERE SI_ID="+UserID);
// Retrieve the Groups collection.
var MemberGroups = User.PluginInterface("").Groups;
// Add the Group to the collection.
MemberGroups.Add(Number(GroupID));
Response.Write ("<BR>Now ID for group is " + GroupID);
Response.Redirect("Start.csp");
var UserID = Request.QueryString.Item ("UserID");
var NewGroupName = Request.Form.Item("NewGroupName");
var AvailableGroupID = Request.Form.Item("GroupList");
var GroupMemberID = Request.Form.Item("MemberGroups");
if (Request.Form.Item("Add") == "Add user to group") AddUserToGroup(IStore,UserID,AvailableGroupID);
if (Request.Form.Item("Remove") == "Remove user from group") RemoveUserFromGroup(IStore,UserID,GroupMemberID);
if (Request.Form.Item("New") =="Create") AddUserToNewGroup(IStore,UserID, NewGroupName);
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |