0

I have an LWC component which is used to display contact information to guest user, using which they can also update the contact details.

When I'm running that LWC component as a system admin, I can see the field values, but as a guest user, I can't see any value.

I have already given class and object access to guest user profiles, also FLS permission is given for all fields.

HTML:

<template>
    <lightning-card>
        <div class="slds-m-around_medium">
            <lightning-input type="text" label="Name" value={Name}></lightning-input>
            <lightning-input type="text" label="Custom Field" value={CustomField}></lightning-input>
        </div>
        <div>
            <lightning-button label="Save"></lightning-button>
        </div>
    </lightning-card>
    
</template>

JS:

import { LightningElement , wire, api, track} from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';

import CONTACT_OBJECT from '@salesforce/schema/Contact';

import CONTACTNAME from '@salesforce/schema/Contact.Name';
import CUSTOMFIELD from '@salesforce/schema/Contact.CustomField__c';

export default class UpdateDealerSocialMedia extends LightningElement {

    @api recordId;
    @track record;
    @track error;
    @track nameValue;
    @track customFieldValue;

    
    @wire(getRecord, { recordId: '$recordId', fields: [CONTACTNAME,CUSTOMFIELD] })
    wiredAccount({ error, data }) {
        if (data) {
            this.record = data;
            console.log('>>> record... '+JSON.stringify(this.record));
            this.error = undefined;
            this.nameValue = this.record.fields.Name.value;
            this.customFieldValue = this.record.fields.CustomField__c.value;
        } else if (error) {
            this.error = error;
            this.record = undefined;
        }
    }
    
}
3
  • I also ran into this just today. Might have something to do with recent guest user critical updates. Try checking if Secure guest user record access in the Sharing Settings is checked, and uncheck it. See if that fixes it. – bblackinton Aug 12 '20 at 21:11
  • @bblackinton I believe the critical updates you are referring to wouldn't apply here. Previously profiles did not require access to the apex class in order for an "@AuraEnabled" method to be leveraged by a component. The critical update resolves that and now enforces that class access be granted to the profile. The poster of this question mentioned that class access was already granted. – rStrunk Aug 13 '20 at 12:38
  • You're right on the critical updates, but Secure Guest User Record Access is not a critical update. Just an idea to see if it solves the problem. – bblackinton Aug 14 '20 at 15:15
1

I feel your pain, according to the new Guest User security, there's a lot less one can do through UI now, here's a good summary: https://help.salesforce.com/articleView?id=networks_guest_policies_timelines.htm&type=5

Also, an alternative method: Flow(Without Sharing) is mentioned here: https://www.isimio.com/2020/08/07/migrating-to-salesforce-secure-site-guest-user/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.