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
SabinaSabina 

lightning/uiRecordApi for Community Users

Hello,

I am trying to use the lightning/uiRecordApi module for an LWC component that is also used in Communities. Everything works fine when internal users view the community; but if I log in as a community user, getRecordUi and getRecord adapters return undefined. The community user has a permission set with API Enabled = true.

 I know these adapters use User Interface API resources and, according to the documentation (https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_get_started_intro.htm), community users should be able to access the API. 

Could anyone help me understand why this is not working, please?

Thanks,
Sabina
Best Answer chosen by Sabina
AnudeepAnudeep (Salesforce Developers) 
getRecordUi works based on the recordId which we pass as an input that wired adapter. Have you verified if the community user has access to that record?
 
SELECT RecordId, HasReadAccess, MaxAccessLevel
     FROM UserRecordAccess
     WHERE UserId = [single ID]
     AND RecordId = [single ID]

Also, can you please post your code? 
 

All Answers

AnudeepAnudeep (Salesforce Developers) 
getRecordUi works based on the recordId which we pass as an input that wired adapter. Have you verified if the community user has access to that record?
 
SELECT RecordId, HasReadAccess, MaxAccessLevel
     FROM UserRecordAccess
     WHERE UserId = [single ID]
     AND RecordId = [single ID]

Also, can you please post your code? 
 
This was selected as the best answer
SabinaSabina
Hi Anudeep,

Sorry to come back to you so late. Yes, the user had view access, but not edit access. My code was somehow trying to fetch the Edit layout too and this is where it was failing. I adjusted the code to work with Read-Only layouts only. 

Thank you!