0

UPDATE 12/29/2020:

For clarity, and as I accepted an answer here, I am posting a new question for additional help with new issues. The new question can be reviewed here.


UPDATE:

I am trying to switch everything from a custom object to SF's object, Opportunity. When everything was linked to the custom object, the code worked perfectly. Why would it be throwing errors on Opportunity object?

  • I only get the Error: Unknown property 'ApexPages.StandardController.Customer_Name__c'
    when my extensions are part of the VF page.

My Extentions are:

public with sharing class IntakeExtension {
    public ApexPages.StandardController Opportunity {get; set;}
    public IntakeExtension(ApexPages.StandardController controller) {
         Opportunity = controller;
    }
    public PageReference save() {
        Opportunity.save();
        return Page.Congratulations;
    }
}
public with sharing class ShouldShowMedSection{
    public ShouldShowMedSection(ApexPages.StandardController paramController) {
       Opportunity = paramController;}
    public ApexPages.StandardController Opportunity {get; set;}
    public Boolean getShouldShowMedSection() {
       Opportunity record = (Opportunity)Opportunity.getRecord();
        
        
          if(
            record.Personal_Care_Concerns__c != null && record.Personal_Care_Concerns__c.contains('Medication')
            ) 
            {
            return true;
            }
      
        
          return false;
        }
        
        }

I've updated 'InputField' to InputText and now get this error Error: Unknown property 'ApexPages.StandardController.Customer_Name__c'


Receiving this error:

Error: Could not resolve the entity from apex:inputField value binding '{!Opportunity.Customer_Name__c}'. apex:inputField can only be used with SObjects, or objects that are Visualforce field component resolvable.

  • I'm in a sandbox and my Opportunity object has a Customer_Name__c field on it. Not sure why I'm getting the error or how to resolve?

Code here:

<apex:page standardController="Opportunity" extensions="IntakeExtension,ShouldShowSHSection,ShouldShowSHwECSection,ShouldShowPERSSection,ShouldShowMedSection,ShouldShowRingSection" standardStyleSheets="false" showHeader="false" sidebar="false">
    
  <apex:stylesheet value="{!$Resource.styleForIntake}"/>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
   
  
  
<body>
<!-- multistep form -->
<apex:form Id="msform" styleClass="form">
  <!-- progressbar -->
  <br></br><br></br>
  <ul id="progressbar">
    <li class="active">Client Info</li>
    <li>Residence </li>
    <li>Concerns </li>
    <li>Tech Comfort</li>
    <li>Recommendation</li>
  </ul>
  <!-- fieldsets -->
 <br></br><br></br>
   <fieldset>
   <br></br><br></br>
    <h2 class="fs-title">Client Information</h2> 
    <h3 class="fs-subtitle">Here, we will gather information specific to the client.</h3> <br></br>
    <p>  
        Client Name (First and Last Initial): <br></br>
        <span class="required-text">*required</span>
        <br></br> 
     </p>
        <apex:inputField styleClass="fieldset" label="Client Name (First and Last Intial):" value="{!Opportunity.Customer_Name__c}"/> 
    <br></br> <br></br>
     <p>  
4
  • Did you create the Customer_Name__c field in this sandbox, or did you deploy it to this sandbox from another sandbox/scratch org? If you didn't create the field in the target sandbox, you need to set up FLS yourself.
    – Derek F
    Commented Dec 22, 2020 at 18:49
  • @DerekF - This field exists within the sandbox. Commented Dec 22, 2020 at 18:54
  • But did you create it in the sandbox? (Specifically the sandbox that you're seeing this error in)
    – Derek F
    Commented Dec 22, 2020 at 18:59
  • @DerekF - I see what you're saying. No, it was not created in the sandbox itself. How can I send FLS for this entire object at once? Commented Dec 22, 2020 at 19:15

2 Answers 2

2

The problem lies in your controller

public ApexPages.StandardController Opportunity {get; set;}
public IntakeExtension(ApexPages.StandardController controller) {
         Opportunity = controller;
    }

The variable Opportunity is bound to the type ApexPages.StandardController. This then confuses the VF compiler when it is resolving {!Opportunity.Customer_Name__c}

What you want is this:

private ApexPages.StandardController ctrl;
public IntakeExtension(ApexPages.StandardController controller) {
             this.ctrl = controller;
        }

Any VF markup that references {!Opportunity.xxx} will reference the current record presented to the standard controller.

If your controller needs access to the Opportunity for logic reasons, add in this property to the controller and then reference o as needed.

Opportunity o {
    get {return this.ctrl.getRecord();}
    set;
4
  • Can you please share with me how I need to update the code in the ShouldShowMedSection controller above to access the logic? I see your note, but am not quite sure where/how to implement. Commented Dec 28, 2020 at 15:17
  • I have added an update above, as it seems like the 'save' feature is also no longer implementing Commented Dec 28, 2020 at 16:01
  • alexis -- since you already accepted the answer; I suggest for clarity - you post a new question with your current code and current issue
    – cropredy
    Commented Dec 28, 2020 at 23:34
  • I have posted a new question here: salesforce.stackexchange.com/questions/329976/… Commented Dec 29, 2020 at 13:54
0

The issue is that Customer_Name__c was not created in the sandbox you're encountering this error in, but rather deployed to it.

When fields are deployed the permissions/FLS do not come along with it, and need to be set. Not even system administrators can read/query the field without doing this (which is the issue you're running into).

Salesforce doesn't really have a quick and easy way to manage profiles/permissions en masse.

If you've deployed only a few fields, the quickest way to manage this is to just go to the field definition (in the SObject) and set the FLS (Field Level Security). If you have more fields (or if you're deploying an entirely new object), then you should look at using a permission set to manage permissions (the downside being that assigning the permission set is a bit of a chore, though hopefully something that only needs to be done once)

2
  • When in the Opportunity object, I'm viewing Field Accessibility and FLS for the Customer Name field - This is showing as 'Editable' for all profiles. I've also gone in and created a Permission set for my login profile and set FLS on all fields w/i the Opp object to editable. I'm still running into the same issue. Any ideas? Commented Dec 22, 2020 at 19:53
  • Even within the production environment, where these fields were created, I am seeing this error Commented Dec 22, 2020 at 20:17

You must log in to answer this question.

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