cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning Group(of users) to Role when starting a process programmatically

Former Member
0 Kudos

Hi All,

I m starting a process programmatically(using startProcess()).

Process initiation is working fine, but i need to assign a 'Group' to the role, and not a user. It is a portal group, available at portal end only. How can this be done?

Please guide.

Thanks and Regards,

Sakshi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Using the UME API you have to fetch the group, iterate it and assign it user by user to the specific role.

Hope that helps.

Best regards,

George.

Former Member
0 Kudos

Hi George,

Yes, I am aware of this approach, but this is equivalent to hard coding the group (or knowing the group name in advance). In my case, user group names are not final and can be changed in future at portal end. Is there any way to handle this?

Also can you please provide some sample code, for the solution that you suggested?

Thanks and Reagrds,

Sakshi.

Former Member
0 Kudos

Hi Sakshi,

I don't that is possible. You have to get the group from the UME API somehow.

As far as I know this is done by Name.

You can try asking in some of the UME forums what be achieved with their API.

My best idea is to make a constant for each group name and use it in your GP API code.

Then if you change the group's name you just go and change the constant's value.

Best regards,

George.

Answers (1)

Answers (1)

Former Member
0 Kudos

you can use the following code

import com.sap.caf.eu.gp.process.api.GPProcessFactory;

import com.sap.caf.eu.gp.process.api.IGPProcess;

import com.sap.caf.eu.gp.process.rt.api.IGPProcessRoleInstanceList;

import com.sap.caf.eu.gp.process.rt.api.IGPRuntimeManager;

import com.sap.security.api.IUser;

public void startProcess( java.lang.String processId )

{

...

// retrieve the Runtime Manager

IGPRuntimeManager rtm = GPProcessFactory.getRuntimeManager();

// create an empty role assignment list

IGPProcessRoleInstanceList roles = rtm.createProcessRoleInstanceList();

// get the process role number

int rolenum = process.getRoleInfoCount();

// iterate over the required roles

for (int i = 0; i < rolenum; i++) {

// create a new role instance by specifying the role's unique name

IGPProcessRoleInstance roleInstance = roles. createProcessRoleInstance(process.getRoleInfo(i).getRoleName());

// add a user to the role instance

roleInstance.addUser(roleUser);

// add the new role to the assignment list

roles.addProcessRoleInstance(roleInstance);

}

Thanks and Regards

shanto aloor

Former Member
0 Kudos

Hi Shanto,

Thanks for help.

I m aware of that piece of code that u sent, but that is for assigning a 'user' to role and not a 'group'.

My requirement is to assign a portal group(that contain 'n' no. of users) to the role.

Any suggestions for that...

Thanks,

Sakshi

Former Member
0 Kudos

you have to fetch the user group using UME API and retrieve each user and assigh the roleinstance to these users seperately i think it will work...

Please check this , iam also checking here

Thanks and Regards

shanto aloor