function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robin BarnwellRobin Barnwell 

Community Home Page - This component has no data

I've set-up a basic community and got it running.  But when I drag components onto the Home Page I get a message such as this: 

Community Home Page

What I'd like to do is put the user details on the home page for editing.  Can this be done?
GhanshyamChoudhariGhanshyamChoudhari
For community, you need to implements  forceCommunity:availableForAllPageTypes in cmp.
Apex
public class userlist {
    @AuraEnabled
    public static List<User> fetchUsers(){
        return [select Id,FirstName, LastName, Email from user limit 10];
    }

}

UserList.cmp
<aura:component controller="userlist" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
	  <aura:attribute name="setMeOnInit" type="User[]"  />
 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    
     <table class="slds-table slds-table_bordered slds-table_cell-buffer">
         <thead>
            <tr class="slds-text-title_caps">
                <th scope="col">
                    <div class="slds-truncate" title="User Id">User First Name</div>
                </th> 
                 <th scope="col">
                    <div class="slds-truncate" title="User Name">User Last Name</div>
                </th> 
                 <th scope="col">
                    <div class="slds-truncate" title="User email">User Email</div>
                </th> 
  
            </tr>
         </thead>
         <tbody>
            <aura:iteration items="{!v.setMeOnInit}" var="user">
               <tr>
                
                 <td><div class="slds-truncate">{!user.FirstName}</div></td>
                   <td><div class="slds-truncate">{!user.LastName}</div></td>
                   <td><div class="slds-truncate">{!user.Email}</div></td>
                 
                   
               </tr>
            </aura:iteration>
         </tbody>
      </table>
</aura:component>

UserListController.js
({
    doInit: function(component, event, helper) {
        var action = component.get("c.fetchUsers");
        
        action.setCallback(this, function(response) {
            if (response.getState() == "SUCCESS") {
                var allValues = response.getReturnValue();
                component.set("v.setMeOnInit",allValues);
                console.log(JSON.stringify(allValues))
            }
        });
        $A.enqueueAction(action);
        
    },
    
})

UserList.app
<aura:application extends="force:slds">
    <c:UserList/>
</aura:application>

 
Robin BarnwellRobin Barnwell
Hello Ghanshyam, many thanks for swift reply.  I got the code working as shown.  But it didn't resolve the issue of using the exsting User Profile component on the home page.

Are you suggest it can't be done and I need to build a custom component to replace the standard component?

User-added image
Robin BarnwellRobin Barnwell
If I change the SQL to just return the current user:
return [select Id,FirstName, LastName, Email from user where id= :UserInfo.getUserId() limit 1];
Then I could change the component to go in edit-mode, that would do the trick
editRecord : function(component, event, helper) {
    var editRecordEvent = $A.get("e.force:editRecord");
    editRecordEvent.setParams({
         "recordId": component.get("v.contact.Id")
   });
    editRecordEvent.fire();
}
Would you mind helping me by changing the component to edit / save please?
CARLOS RODRIGO DEL TORO ORTIZCARLOS RODRIGO DEL TORO ORTIZ
could you fix this problem?