cancel
Showing results for 
Search instead for 
Did you mean: 

Removing Users assigned to a role dynamically

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi,

We found out after many trys that once a user is assigned to a role he cannot be removed in GP. In monitoring it is indicates the user being removed. But still if we are in the removed users log-in and if we give refresh from the previous action that user can very well see the action from which he was removed.

I think this is a bug with GP.

Thanks for reply Pedro.

Regards,

Srinivasan Subbiah

kiran_jakkaraju
Contributor
0 Kudos

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?

Former Member
0 Kudos

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)

😎 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