i got this visualforce page (i will only paste the relevant part) :

This is the first block of the page

<apex:pageBlock title="Data input" id="di" tabStyle="lead"> 
    <apex:outputPanel id="userLookup_ActiveUsers">
    <apex:pageBlockSection columns="6" id="UserSelection1">
        <apex:pageBlockSectionItem id="FromUser1" rendered="{!isNotSales}">
            <apex:outputLabel >Sales person:</apex:outputLabel>
            <apex:inputField value="{!auxFields.OwnerId}" id="SalesP" required="false"  />
        <apex:pageBlockSectionItem id="StartDate">
            <apex:outputLabel >Since:</apex:outputLabel>
            <apex:inputField value="{!auxFields.StartDate}" required="false" id="StartD" />
        <apex:pageBlockSectionItem id="EndDate">
            <apex:outputLabel >To:</apex:outputLabel>
            <apex:inputField value="{!auxFields.EndDate}" required="false" id="EndD" />
    <apex:pageBlockButtons location="bottom"> 
        <apex:actionStatus id="loadingSearch" ><apex:facet name="start"><apex:image value="/img/loading.gif"/></apex:facet></apex:actionStatus>                   
        <apex:commandButton value="Refresh" action="{!doRefreshData}" id="removeButton" rerender="theForm" status="loadingSearch" oncomplete="reload();"/>

First the field Ownerid was null by default but only System admins could see this page. Now they asked me to made it visible for salespeople too, but they can only see their own user stats.

What i did was to initialize the value on the controller with the current user and if the profile of the person isn't System admin put the rendered of this field to false.

This is controller's code that i modified:

public without sharing class ReportFunnelAnalysis {

    public Campaign auxFields                     {get;set;}
    public List<Decimal> grandTotals              {get;set;}
    public Map<String,DataObject> inboundSources  {get;set;}
    public Map<String,DataObject> outboundSources {get;set;} 

    public boolean isNotSales {get;set;}
    public User userloggedin {get;set;}

    public List<PieWedgeData> inboundRevenue      {get;set;}
    public List<PieWedgeData> outboundRevenue     {get;set;}    
    public List<PieWedgeData> allRevenue          {get;set;}

    public ReportFunnelAnalysis(){
        isNotSales = System.UserInfo.getProfileId()!='00eb0000000UqLg';
        auxFields = new Campaign(OwnerId=System.UserInfo.getUserId(), StartDate = Date.newInstance(System.today().year(), System.today().month(), 1), EndDate=System.today()); 

The Ownerid of the campaign wasn't declared before the change request so it was initialized to null.

But this had a collateral effect, which was that now i can't edit dates. I paste screencaps: Before editing for sales people: http://puu.sh/l2XW3/ef6ce20e62.png

Now: http://puu.sh/l2Y5X/66929ddb10.png

Why did the Date fields were affected by the changes in code? if i only edited the rendered blocksection items related to the owner?

Which way would you do it so the admins can search for any user and salesperson can only see their own but being able to edit dates?

  • 1
    most probably the role hierarchy causing this effect. Provide read permission for user object and edit permissions for date fields (Field level security).
    – Ashwani
    Oct 30, 2015 at 8:16
  • They have Edit permission for that Date fields for the Campaign object. They can't edit the date fields tho. Oct 30, 2015 at 9:45

1 Answer 1


It was related to the fact that they hadn't market the user Detail Checkbox 'Marketing User'. So they couldn't take advantage of the Campaign object that was used on apex to store the 'Sales' person.

You must log in to answer this question.

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