• bret_w
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi there,
 
I'm trying to list all direct reports for the logged in User using User and UserRole.
 
I'm querying the UserRole tables ParentRoleID field to find any children of the parent, then going back to the User table to find the users login id.
 
Here is my controller:
 
Code:
public class FindReports {

public List<UserRole> getMyRoles() {
    //return [Select u.UserRole.Name, u.UserRole.Id, u.UserRoleId, u.Alias From User u WHERE u.UserRoleId != null LIMIT 10];
 return [Select u.Name, u.Id, (SELECT Alias FROM Users) From UserRole u WHERE u.ParentRoleId = :UserInfo.getUserRoleId()];

}

}

 
I can't seem to access the "Alias" from the Users object in my VisualForce code:
 
Code:
<apex:page Controller="FindReports" tabStyle="Account">
 
 <apex:pageBlock title="My Reports Roles">
 
 <apex:dataTable value="{!myRoles}" var="aRole" cellpadding="2" rowClasses="odd,even" styleClass="tableClass">
     <apex:column >
      <apex:facet name="header"><b>Role Name</b></apex:facet>

      {!aRole.Name}
     </apex:column>
     <apex:column >
      <apex:facet name="header"><b>Role ID</b></apex:facet>
      {!aRole.Id}
     </apex:column>
 <apex:column >
      <apex:facet name="header"><b>User 6+2</b></apex:facet>
      <!--  {!aRole.Users.Alias}  -->
     </apex:column>
   </apex:dataTable>   
  </apex:pageBlock>
 
 
</apex:page>

 I can't find "Alias" in the returned Object: java.util.ArrayList does not have the property "Alias".
 
Thank you!
 
 
Hi there,
 
I'm trying to list all direct reports for the logged in User using User and UserRole.
 
I'm querying the UserRole tables ParentRoleID field to find any children of the parent, then going back to the User table to find the users login id.
 
Here is my controller:
 
Code:
public class FindReports {

public List<UserRole> getMyRoles() {
    //return [Select u.UserRole.Name, u.UserRole.Id, u.UserRoleId, u.Alias From User u WHERE u.UserRoleId != null LIMIT 10];
 return [Select u.Name, u.Id, (SELECT Alias FROM Users) From UserRole u WHERE u.ParentRoleId = :UserInfo.getUserRoleId()];

}

}

 
I can't seem to access the "Alias" from the Users object in my VisualForce code:
 
Code:
<apex:page Controller="FindReports" tabStyle="Account">
 
 <apex:pageBlock title="My Reports Roles">
 
 <apex:dataTable value="{!myRoles}" var="aRole" cellpadding="2" rowClasses="odd,even" styleClass="tableClass">
     <apex:column >
      <apex:facet name="header"><b>Role Name</b></apex:facet>

      {!aRole.Name}
     </apex:column>
     <apex:column >
      <apex:facet name="header"><b>Role ID</b></apex:facet>
      {!aRole.Id}
     </apex:column>
 <apex:column >
      <apex:facet name="header"><b>User 6+2</b></apex:facet>
      <!--  {!aRole.Users.Alias}  -->
     </apex:column>
   </apex:dataTable>   
  </apex:pageBlock>
 
 
</apex:page>

 I can't find "Alias" in the returned Object: java.util.ArrayList does not have the property "Alias".
 
Thank you!