Skip to Content
avatar image
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Sep 27, 2008 at 07:24 AM
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.