0

I'm developing on a scratch org with Salesforce Sites enabled.

My Visualforce page code:

 <apex:page controller="myAccountController">
    <apex:form>
        <apex:inputField value="{!account.Name }"/>
        <apex:commandButton action="{!save }" value="save" />
    </apex:form>
</apex:page>

Custom controller:

public class MyAccountController {
public MyAccountController() {
  this.account = [
      SELECT Id, Name
      FROM Account
      WHERE Id = :ApexPages.currentPage().getParameters().get('id')
    ];
}

public Account account {get;set;}
public PageReference save() {
    update account;
    return null;
  }
}

The Public Access Settings has Edit Access checked on the Account Field-Level Security.

The inputField displays but I can't edit it. What do I need to do to make it editable? Thank you

5
  • the fact that you are displaying $User.FirstName suggests you have authenticated users on this Community (as otherwise, this value makes no sense for guest users). This would imply you need to look at some Community user profile for CRUD
    – cropredy
    Commented Jun 21, 2021 at 21:55
  • sorry $User.FirstName was just pasted from an example. It's really the Guest User.
    – T. Webster
    Commented Jun 22, 2021 at 13:17
  • What is the "external access" setup on this object (sharing settings - OWD)? Is it private or read only? Commented Jun 22, 2021 at 15:36
  • @KannanNarayanan I've updated the post to include custom controller code. It doesn't have with sharing. Which external access settings would I need to modify?
    – T. Webster
    Commented Jun 23, 2021 at 15:28
  • This article says "Guest users aren't considered external users. Guest users’ org-wide defaults are set to Private for all objects, and this access level can’t be changed."
    – T. Webster
    Commented Jun 23, 2021 at 15:30

2 Answers 2

0

I am able to see the field as editable and did the below:

<apex:page standardController="Account" showHeader="false" cache="false" lightningStylesheets="true" applyHtmlTag="true">
   <apex:form >
      <apex:inputField value="{!account.Name}"/>
      <apex:commandButton action="{!save}" value="save" />
   </apex:form>
</apex:page>

On VF page, Available for Lightning Experience, Experience Builder sites, and the mobile app i enabled this.

Profile:

I gave Read and Create access on Guest User License, and also made sure i added my VF page to Visualforce Page access.

Below is my site detail screen if it helps. enter image description here

0
0

I found a workaround to make the inputField editable:

<apex:page controller="myAccountController">
    <apex:form>
        <apex:inputField value="{!account.Name }" ignoreEditPermissionForRendering="true"/>
        <apex:commandButton action="{!save }" value="save" />
    </apex:form>
</apex:page>

Set ignoreEditPermissionForRendering to 'true'.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .