cancel
Showing results for 
Search instead for 
Did you mean: 

Adding roles to a group using WebDynpro java

Former Member
0 Kudos

Hi All,

I am developing one application to assign portal roles and users to a group at the time of new group creation using WebDynpro java coding.

So I have manage to add the users to that group but not being able to add roles to that group.

So can anyone please suggest me how to do this.

Thanks & Regards

Mainak

Accepted Solutions (1)

Accepted Solutions (1)

michael_voss2
Participant
0 Kudos

Hi Maniak!

I guess you are using an IGroup instance. You can add an IGroup instance to a role with a known name using the IGroup.addToRole(String roleName) method. There are also methods like removeFromRole(String roleName) and getRoles(boolean recursive). If you've got the IRole instance, you can use IRole.addGroupMember(String groupName) to add a Group to the IRole instance. Funny enough, there are no methods to add an IGroup instance to an IRole instance, though...

Hth

Michael

Former Member
0 Kudos

Hi Michael,

Thanks a lot for your reply.

I am new to the WebDynpro java, So if you please give me one example for this, then it will be great for me.

Once again Thanks .

Regards

Mainak

michael_voss2
Participant
0 Kudos

O.k., you might go with something like this (unchecked code, so be careful for typos or the like...)

IGroupFactory gf = UMFactory.getGroupFactory();

IGroup group = factory.getGroup("YourGroup.Name.GoesHere");

// if you are to create a group, use

// IGroup group = factory.newGroup(String);

// group.save();

// Maybe you'll have to commit here:

// group.commit();

group.addToRole("YourRole.Name.GoesHere");

group.save();

group.commit();

hth

Michael

Former Member
0 Kudos

Hi  Michael,

Thanks a lot for your help.

I have done this and it is working fine.

Regards

Mainak

Answers (0)