[SalesForce] Get record in in lightning component in communities

I want to created a component that would be used on a record detail page in a community
The component I created co far implements force:hasRecordId (and few more) but the id I get on run time in null.

flexipage:availableForRecordHome,
flexipage:availableForAllPageTypes,
force:hasRecordId,force:hasSObjectName,
forceCommunity:availableForAllPageTypes

What am I doing wrong. Is the feature only available for home pages?

Best Answer

use force:hasRecordId as documented here

For the Experience builder the way I have managed to get the record ID is as below

Create an attribute

<aura:component implements="forceCommunity:availableForAllPageTypes,flexipage:availableForAllPageTypes,force:hasRecordId">

 <!--ATTRIBUTES DECLARATION -->

 <aura:attribute name="recordId" type="String" default="{!recordId}"/>
   <aura:handler name="init" value="{!this}" action="{!c.getrecord}" />
 </aura:component>

Let's get the Id now in our JS controller

({
   getresults: function(component, event, helper) {
    console.log(component.get("v.recordId"));//print the Id 
    
  }
})