• vanya
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies

Code has worked in the past, and suddenly stopped.  I have simplified it as much as possible ...

 

VF Page:

 

<apex:page standardController="Event">
<apex:form> 
Start: &nbsp;&nbsp; <apex:inputField value="{!event.startdatetime}"/><br/>
End: &nbsp;&nbsp;  <apex:inputField  value="{!event.enddatetime}" /><br/>
<apex:commandButton value="Save"  action="{!save}"/>
</apex:form>

</apex:page>

 

Please assist.

 

Vanya

  • January 06, 2010
  • Like
  • 0

Ultimate purpose:  Dynamically display (or not) a field label/value without using profiles ... (It would take a single profile per user). The dynamic part works fine. It just looks pretty awful.

 

 I would like to display a field using the standard page's style, but I keep getting extra UI elements.  Like a blue line around the field and the columns don't line up with the other columns in the section.

 

 If I remove pageBlockSection, I don't get the label displayed nicely with the field value ... I only get the formatted field value.

 

 If I remove pageBlock, I get a white box containing an unformatted field value.

 

 FYI, The VF page is inserted into the Account Page layout as an element.

 

I've included the code below.  I'm brand new to this but I keep reading that the salesforce style is embedded automatically if you use VF, so I'm certain I'm missing something small.  Any and all help will be much appreciated.

 

Vanya

 

 Here is VF page code:

<apex:page standardController="Account" extensions="AcctSalesRevenueControllerExtension" tabStyle="Account">
    <apex:pageBlock >
        <apex:pageBlockSection collapsible="false"  columns="2" showHeader="false" >
           <apex:outputField rendered="false" value="{!account.PB_Salesperson_1_ID__c}" />
           <apex:outputField rendered="false" value="{!account.PB_Salesperson_2_ID__c}" />
           <apex:outputField rendered="false" value="{!account.PB__c}" />
           <apex:outputField value="{!account.PB__c}" rendered="{!renderRevenue}" id="revenueID"/>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>

Here is the Apex class code:

public class AcctSalesRevenueControllerExtension {

    private final Account acct;
    private final String sid1;
    private final String sid2;
    private final String usrSid;
   
    public AcctSalesRevenueControllerExtension (ApexPages.StandardController stdController) {
       this.acct = (Account)stdController.getRecord();
      
        ID usrId = UserInfo.getUserId();
        this.usrSid = getSidFromUserID(usrId );
       
        
        ID id1 = acct.PB_Salesperson_1_ID__c;
        if (id1 == null){
            sid1 = 'id1 notfound in acct';
        }
        else {
             sid1 = getSidFromEmpID(id1);
        }
        if (sid1 == null){
            sid1 = 'sid1 notfound for id:' + id1 ;
        }


        ID id2 = acct.PB_Salesperson_2_ID__c;
        if (id2 == null){
            sid2 = 'id2 notfound in acct';
        }
        else {
             sid2 = getSidFromEmpID(id2);
        }
        if (sid2 == null){
            sid2 = 'sid2 notfound for id:' + id2 ;
        }
    }
    private Boolean shouldRevenueDisplay(){
        Boolean result = false;
        if (this.usrSid != null)
            {result = (usrSid == sid1 || usrSid == sid2);}
        return (result);
    }
    private String getSidFromUserID(ID userId){
            Employee__c emp =[select id, name,JPM_SID__c,Title__c from Employee__c where User__c = :userId];
             String userSid = emp.JPM_SID__c;
         if (userSid == null){
             userSid = 'userSid not found';
         }
         return (userSid);
    }
    private String getSidFromEmpID(ID empId){
            Employee__c emp =[select id, name,JPM_SID__c,Title__c from Employee__c where id = :empId];
             String userSid = emp.JPM_SID__c;
         if (userSid == null){
             userSid = 'userSid not found';
         }
         return (userSid);
    }
    public Boolean getRenderRevenue(){
        return (shouldRevenueDisplay());
    }
   
   
}

  • July 07, 2009
  • Like
  • 0

Code has worked in the past, and suddenly stopped.  I have simplified it as much as possible ...

 

VF Page:

 

<apex:page standardController="Event">
<apex:form> 
Start: &nbsp;&nbsp; <apex:inputField value="{!event.startdatetime}"/><br/>
End: &nbsp;&nbsp;  <apex:inputField  value="{!event.enddatetime}" /><br/>
<apex:commandButton value="Save"  action="{!save}"/>
</apex:form>

</apex:page>

 

Please assist.

 

Vanya

  • January 06, 2010
  • Like
  • 0