cancel
Showing results for 
Search instead for 
Did you mean: 

Adding users to a process role at runtime method :- addRuntimeDefinedUser

Amey-Mogare
Contributor
0 Kudos

Hi All,

I have a requester - approver process where I want to assign list of users to Processor for Approval role.

I am getting list in requester CO and at design-time I have declared Processor for Approval as runtime defined in roles tab of process.

Can anybody tell me how to add this users to this role programmatically? may b in execute method or in complete() method?

I came across with one method which looks promising :


IGPRuntimeManager rtManager = GPProcessFactory.getRuntimeManager();

rtManager.addRuntimeDefinedUser();

This method requires IGPProcessInstance and other parameters. Can I get some info abt how to get them?

Sample code will be most welcome.

Thanks and regards,

Amey Mogare

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user2 = wdUser.getSAPUser();

IGPUserContext userContext = GPContextFactory.getContextManager().createUserContext(user2);

IGPProcessInstance prInstance = rtm.getProcessInstance(executionContext.getProcessId(), userContext);

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

you can get those parameters from the executionContext parameter present in the execute() method

Amey-Mogare
Contributor
0 Kudos

Hi,

Thank u for prompt reply.

I tried n searched many ways. but I haven't got any success with it. Can you please put up any coding lines to get IGPProcessInstance n other params.

thanks n regards,

Amey Mogare

Former Member
0 Kudos

Hi,

IUser user=UMFactory.getUserFactory().getUserByLogonId(userId);

executionContext.getProcessRoleInstance().addRuntimeDefinedUser(user);

Amey-Mogare
Contributor
0 Kudos

Hi,

Thank you for helpful replies.

I am trying following piece of code inside execute() method of RequesterCO, but when I check Worklist of approver user, its empty. That means this user is not getting assigned to this process role.

(Before that in roles tab of process, i have defined "Processor for Approval" as runtime defined.)



IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
	
IUser userJames = UMFactory.getUserFactory().getUserByLogonID("James.bond");

IGPUserContext userContext = GPContextFactory.getContextManager().createUserContext(userJames);
	
IGPProcessInstance prInstance = rtm.getProcessInstance(executionContext.getProcessId(),userContext);
	
rtm.addRuntimeDefinedUserToRole(prInstance, "Processor of NewApprovalAction", userJames, userContext);

Can you please suggest? And is it possible to add more than one user to same process role using above way?

Regards,

Amey Mogare

Edited by: Amey Mogare on Nov 19, 2008 4:14 PM

Edited by: Amey Mogare on Nov 19, 2008 4:30 PM

Amey-Mogare
Contributor
0 Kudos

Oops !!!

I got it. Actually you are supposed to enter Technical name of the action as role in this method...

So when I did it, it worked !!!


IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();
	
IUser userJames = UMFactory.getUserFactory().getUserByLogonID("James.bond");
IUser userSuperman = UMFactory.getUserFactory().getUserByLogonID("Super.man");

IGPUserContext userContext1 = GPContextFactory.getContextManager().createUserContext(userJames);
IGPUserContext userContext2 = GPContextFactory.getContextManager().createUserContext(userSuperman);
	
IGPProcessInstance prInstance = rtm.getProcessInstance(executionContext.getProcessId(),userContext1);
IGPProcessInstance prInstance = rtm.getProcessInstance(executionContext.getProcessId(),userContext2);

	
rtm.addRuntimeDefinedUserToRole(prInstance, "Action_3", userJames, userContext1);
rtm.addRuntimeDefinedUserToRole(prInstance, "Action_3", userSuperman, userContext2);

This adds the James.bond and Super.man to role "Processor of ApprovalAction" that is "Action_3" !!!

Thanks a lot for your replies guys !!! It helped to achieve it.

Regards,

Amey Mogare