BMC - facility to add role in advanced functions

Mayur Randive shared this question 21 months ago
Answered

Dear Team,

While creating advanced functions, can we add user roles into parameters so that based on role we can modify the data.

e.g.

	    public Object applyAnalyticFunction(int index, Object value) throws Exception
	    {		
	    	  if (role == 'System Administrator'){ 
	    		    return value;
	    		  }else{ 
	    		    return "Restricted Data"; 
	    		  }

	    }

role is something which we could handle in preAnalyticFunction

Please let me know if you have any question.

Thanks,

Mayur

Comments (8)

photo
1

Hey Mayur,

You can access the current user's information through the session bean:

       SessionBean sb = i4RequestRegistry.getInstance().getCurrentSessionBean(); 
       sb.getCurrRole() 


Let me know if this makes sense.

Regards,

Nathan

photo
1

Hi Nathan,

This is useful, but is there any way by which we can list all available roles in system on parameter selection section.

The way we provide facility to select other column by setting up parameter, similarly can we provide a drop down from where user can select a role available in the system.

Please let me know if you have any question.


Thanks,

Mayur

photo
1

Hi Mayur,

This would need to be done by adding these as available options to a "SELECT" type parameter.

You should be able access all roles through:

sb.getCurrRoles()

You can then loop through this result in your parameter setup section, adding these as options so something along the lines of:

for (role: roles){
p.addOption(role)
}


Let me know if this works for you.

Nathan

photo
1

Hi Mayur,

Sorry that will not produce the right results but the idea applies. I do not have access to the codebase today as we are snowed in, but I will look tomorrow and get the right call to list those roles.

Regards,

Nathan

photo
1

Hi Mayur,

You should be able to get the roles by using:

DBAction db = new DBAction(); 
ArrayList roles = new ArrayList(); 
MIAdminProcess.loadAllRoles(db, roles); 
Iterator i = roles.iterator();


Let me know if this works for you.

Regards,

Nathan

photo
1

Hi Nathan,

Thank you for your response, I didn't get time to check on this.

Can you please give me sometime, will update you soon on this.

Thanks,

Mayur

photo
1

Sounds good.

Regards,

Nathan

photo
1

Hi Mayur,

Closing this, but if you need anything from me, just reply and the ticket will be automatically re-opened!

Nathan