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
programmer4hireprogrammer4hire 

Field on Visualforce page is read-only when it should not be

I am working on a visualforce page so that users can create certain opportunities (it's similar to a wizard, but it is only 1 page).  For some users, the Account Name field is read-only.  The administrators say that those people have the correct permissions, so is there anything that I can check or implement in order for the field to appear as an inputfield for them?  Thanks.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
programmer4hireprogrammer4hire

The profile for the users that had the problem cannot created Account records, only read and edit them. The users were able to see the field on regular opportunity pages, so it had to do with the tag I used on my Visualforce page.

 

I had this tag:

<apex:inputField value="{!account.Name}" required="true"/>

with this getter and setter on the extension:

public Account getAccount() {
if( acc == null ) {
acc = new Account();
}
return acc;
}

public void setAccount( Account acc ) {
this.acc = acc;
}

So, as it was explained to me, if the account is null, which it will be the first time, then a new account is created. An account is not really submitted, but it is created.

 

To fix this, I replaced the tag with this:

<apex:inputfield value="{!Opportunity.AccountID}"/>

Not only were the users now able to see the field, but the Account lookup button was now next to the field as well.

All Answers

srisomsrisom
It does sound like a permissions issue.  For a user that has the issue, what do the standard Salesforce screens show for the same fields ?
programmer4hireprogrammer4hire

The profile for the users that had the problem cannot created Account records, only read and edit them. The users were able to see the field on regular opportunity pages, so it had to do with the tag I used on my Visualforce page.

 

I had this tag:

<apex:inputField value="{!account.Name}" required="true"/>

with this getter and setter on the extension:

public Account getAccount() {
if( acc == null ) {
acc = new Account();
}
return acc;
}

public void setAccount( Account acc ) {
this.acc = acc;
}

So, as it was explained to me, if the account is null, which it will be the first time, then a new account is created. An account is not really submitted, but it is created.

 

To fix this, I replaced the tag with this:

<apex:inputfield value="{!Opportunity.AccountID}"/>

Not only were the users now able to see the field, but the Account lookup button was now next to the field as well.

This was selected as the best answer