Skip to Content
avatar image
Former Member

Remove User SDK code not working

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()));

Add comment
10|10000 characters needed 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

  • Get RSS Feed

2 Answers

  • Best Answer
    Jul 12, 2017 at 05:53 AM
    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();
    	    }
    }
    
    Add comment
    10|10000 characters needed characters exceeded

  • Jul 12, 2017 at 06:03 AM
    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();
            }
    }
    Add comment
    10|10000 characters needed characters exceeded