1

I have a visualforce form with 3 entry fields, 2 of which work for all profiles but one doesn't. It works for admin profile though. I've checked the VF security setting and field level security on objects but to no avail. Please help! The lookup is using the PriceBookEntry Product as a lookup, as it has to search OrderItem products for a match.

This is what the page looks like for Admin profile:

enter image description here

This is what it looks like for all other profiles: enter image description here

The code for the page section:

<apex:pageBlockSection title="Search by Account/Product">
    <apex:inputField id="acct" label="Account" value="{!rma.AccountId}" required="false"/>
    <apex:inputField id="prod" label="Product" value="{!pbe.Product2Id}" required="false"/>
</apex:pageBlockSection>

The security for the VF page (users are of the CSR/IPC profiles):

enter image description here

These same profiles can see the field in my Dev environment, but not in my Partial environment. I've compared profiles and the Partial environment has more access than in Dev, yet the field doesn't show. The PBE access for the profiles is the same in Dev as in Partial, so is Product and OrderItem. What have I missed?

Here are the field accessibility comparisons for the SysAdmin profile and CSR profile: enter image description hereenter image description hereenter image description here

  • 2
    Go to the product field and click on "view field accessibility" and see if it is read only for the profiles which do not see the lookup – Rao May 22 '17 at 21:59
  • I've double checked field accessibility on all fields on Product, Pricebook, PriceBookEntry, OrderItem for the CSR profile and compared them from Dev to Partial - all fields related to product have the same accessibility. I've also compared them for System Admin to CSR and also no different... argh! – Irene May 22 '17 at 23:15
  • I've edited the post to show the comparisons between the SysAdmin and CSR profiles on Partial sandbox. – Irene May 22 '17 at 23:49
4

The field accessibility will show access to the fields assuming they profile has access to the object.

Ensure the profile has edit or create access to the PriceBook object and at least read on the product since you are coming from the object pricebookentry in your class

Here is an example for you:

  1. Profile: PriceBook (Read)
  2. Profile: Product (Read)

Apex Class

public class productTestController{

    public PriceBookEntry pbe {get;set;}
    public Opportunity opp {get;set;}
    public productTestController(){
        pbe = New PriceBookEntry();
        opp = New Opportunity();
    }

}

Visualforce Page

<apex:page Controller="productTestController">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!Opp.AccountId}" label="Account"/>
                <apex:inputField value="{!pbe.Product2Id}" label="Product"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Result

enter image description here

Now, Update the profile to provide create or edit (whichever you choose) access to the Price Book object

Result

enter image description here

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.