cancel
Showing results for 
Search instead for 
Did you mean: 

to compare whether a user has a role assigned and to perform an activity.

Former Member
0 Kudos

Hi Experts,

I have used the below code to get the roles assigned to a particular user.

I need to find whether my role Role:A is in the list.

If it is present in the list then i have to perform some activity like hidding some fileds from the view and displaying others.

IWDClientUser wdUser = WDClientUser.forceLoggedInClientUser();
		IUser user = wdUser.getSAPUser();
		String strRoleID = "", strRoleDesc = "";

		IRoleFactory iRoleFactory;
		iRoleFactory = UMFactory.getRoleFactory();

//		   Get All the Roles of the User
		Iterator iteratorRoles = user.getRoles(true);//prtRequest.getUser().getRoles(true);

//		   Loop through all the Roles
		while(iteratorRoles.hasNext())
		{
		strRoleID = iteratorRoles.next().toString();
		try 
		{
		strRoleDesc = iRoleFactory.getRole(strRoleID).getDescription();

String str = "ALSS"; 
		if((strRoleDesc).trim().equals(str))
		{
		wdContext.currentContextElement().setSecondCont(WDVisibility.VISIBLE);
		wdContext.currentContextElement().setDebug("1");


}
		else
		{

wdContext.currentContextElement().setSecondCont(WDVisibility.BLANK);

When i use this my code goes to the else part. And I have checked that the role ALSS is present in the list. Please advice where i am going wrong.

Points will be given for helpful answers.

Regards,

Sanjyoti.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Former Member
0 Kudos

hi,

Thank you for ur reply.

In this case the user will have authentication to use the application.

But depending on the role attached to the user i will display some particular fields to one user and other fields to other users.

ROLE :A App-->Element 1

ROLE: B App->Element 2

In this case the App ie. the application is the same just the elements displayed differs.

Regards,

Sanjyoti.

Answers (0)