Skip to Content
0

Remove User SDK code not working

Jul 10, 2017 at 07:20 AM

64

avatar image

Hello Experts,

I have written a code to Add and remove a user from a User Group. The add function works as expected. But the remove code does not work.

Below is the add code:

boGroup1 = (IUserGroup)boInfoStore1.query("SELECT * FROM CI_SYSTEMOBJS WHERE SI_PROGID='CrystalEnterprise.USERGROUP' AND SI_NAME='Test - User Group'").get(0);

boUserInfo1.getGroups().add(new Integer(boGroup1.getID()));

Below is the Remove Code:

boGroup1 = (IUserGroup)boInfoStore1.query("SELECT * FROM CI_SYSTEMOBJS WHERE SI_PROGID='CrystalEnterprise.USERGROUP' AND SI_NAME='Test - User Group'").get(0);

boUserInfo1.getGroups().remove(new Integer(boGroup1.getID()));

10 |10000 characters needed characters left characters exceeded

Hi,

Are you trying to remove User Group or User.

Code above seems to be for User Group, Instead try with CrystalEnterprise.User’

“SELECT SI_ID From CI_SYSTEMOBJECTS Where SI_PROGID=’CrystalEnterprise.User’ and SI_NAME in (‘USER_1′,’USER_2’)”);

Thanks,

Jothi

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Bharath B N Jul 12, 2017 at 05:53 AM
1
void removeUserToUserGroup(IEnterpriseSession enterpriseSession) throws SDKException
{
       IInfoStore infostore = (IInfoStore)enterpriseSession.getService("InfoStore"); 
       String query = "SELECT * FROM CI_SYSTEMOBJECTS where SI_NAME='test_ug' AND SI_KIND='UserGroup'";
       IInfoObjects infoObjects = (IInfoObjects) infostore.query(query);
       int userID = 85387;
       if(infoObjects.size() > 0)
	   {
	      IUserGroup userGroup = (IUserGroup) infoObjects.get(0);
	      Set usersOfGroup = userGroup.getUsers();
	      usersOfGroup.remove(userID);
	      userGroup.save();
	    }
}
Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks alot. It worked

0
Bharath B N Jul 12, 2017 at 06:03 AM
0
void addUserToUserGroup(IEnterpriseSession enterpriseSession) throws SDKException
{
       IInfoStore infostore =(IInfoStore)enterpriseSession.getService("InfoStore"); 
       String query="SELECT * FROM CI_SYSTEMOBJECTS where SI_NAME='test_ug' AND SI_KIND='UserGroup'";
       IInfoObjects infoObjects =(IInfoObjects) infostore.query(query);
       int userID =85387;
       if(infoObjects.size()>0)
       {
	      IUserGroup userGroup =(IUserGroup) infoObjects.get(0);
              Set usersOfGroup = userGroup.getUsers();
	      usersOfGroup.add(userID);
	      userGroup.save();
        }
}
Share
10 |10000 characters needed characters left characters exceeded