Skip to Content
avatar image
Former Member

Removing Users assigned to a role dynamically

Hi,

We have a process. In each block we have used "Assign Users to process role" callable object for assigning a set of users to the role of that block. But in a scenario we want to replace the existing users with a new set of users. Is there any way of doing this using GP API.

In simple terms we want to remove the users assigned to a role dynamically. We tried the code

IGPProcessRoleInstance processRoleInstance=executionContext.getProcessRoleInstance();
processRoleInstance.removeUser(IUser);

We also tried

IGPRuntimeManager rtm=GPProcessFactory.getRuntimeManager();
rtm.changeTaskProcessor(processInstanceId, activityInstanceId, currentUserContext, newUserContext);

None of them are helping. They are also not throwing any exception. But using the same IGPProcessRoleInstance we could add a runtimeDefinedUser.

Is it actually possible to remove or replace the user for a role. If so is there any other api or way through which it could be achieved. Would appreciate quick inputs.

Thanks in advance.

Thanks and Regards,

Srinivasan Subbiah

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 20, 2008 at 09:38 PM

    Hi Srinivasan,

    I try to simulate your scenario and I got success with the test.

    Follow my steps:

    1) Start a process (1 block and 1 action) and define the current processor as u201Cuser1u201D user;

    2) http://<host>:<port>/nwa -> Monitoring -> Guided Procedures -> Process Instances and fill the filter with Running Instances , owner = u201Cuser1u201D;

    3) Select the process in grid and click in Process Items button;

    4) Click on first line (process) and copy the ID (in my case is 3a7);

    5) Expand Block and Click on action line and copy the id (2a0);

    6) Checking in Processor tab, the user u201Cuser1u201D is defined as processor;

    7) Fill the webservices (code below) parameters with values (3a7, 2a0, u201Cuser1u201D and u201Cuser2u201D)

    8) The current processor now is changed from u201Cuser1u201D user to u201Cuser2u201D user.

    	public boolean changeTaskProcessor(String processInstanceID, String activityInstanceID, String currentProcessorLogonID, 
    									String newProcessorLogonID) {
    		
    		IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
    		try
    		{
    			IUser userCurrentProcessorLogonID = UMFactory.getUserFactory().getUserByLogonID(currentProcessorLogonID);
    			IUser userNewProcessorLogonID = UMFactory.getUserFactory().getUserByLogonID(newProcessorLogonID);
    			IGPUserContext currentProcessor = GPContextFactory.getContextManager().createUserContext(userCurrentProcessorLogonID);
    			IGPUserContext newProcessor = GPContextFactory.getContextManager().createUserContext(userNewProcessorLogonID);
    			rtm.changeTaskProcessor(processInstanceID, activityInstanceID, currentProcessor, newProcessor);
    			return true;
    		}
    		catch(GPInvocationException e)
    		{
    			return false;
    		} catch (Exception ex) {
    			return false;
    		}
    	}
    

    Best Regards,

    Pedro Nunes

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 03, 2009 at 04:05 PM

    Hi Pedro,

    Your solution only seems to work for GP actions that are running, and not for the actions that are pending.

    It seems an action does not have any processors, until it reaches the running status.

    Do you know a way to remove users from actions which are pending?

    I have only found the addRuntimeDefinedUserToRole method, which allows you to add additional users to a pending action, but I cannot find a way to remove or replace users.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      I tried using the following for my process where the action is yet to happen

      I am calling the BG CO before my action. I need to remove the previous user.

      rtm1.removeTaskProcessor(prInstance1.getID(),activityInstanceID, userContext1);
      rtm.changeTaskProcessor(processInstanceID, activityInstanceID, currentProcessor, newProcessor);
      processRoleInstance.removeUser(UMFactory.getUserFactory().getUserByLogonID(UserId));
      

      but nothing is working.

      any idea when we can use them? I think changeTaskProcessor will not work for pending tasks.

      I am able to get the activityInstanceID from NWA -> GP Processes, but my GP Process is having dynamic loop where the task will generate depending on levels. How can we get the activityInstanceID of the next task/action?