• MayeUPAEP
  • NEWBIE
  • 64 Points
  • Member since 2009

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

Hi, I need help in developing a custom formula field that calculates the Age from a given date, in terms of years and months, like this:

 

MyDate: 18/05/1990  (dd/mm/yyyy)

 

Calculated Age: 19 year(s), 11 month(s)

 

I have tried several formulas, but I only could get the year and I got problems with the months calculation.

 

Could someone help with this?

 

Regards,

 

Wilmer

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

When you have a contact email address wrong, Salesforce puts a yellow warning icon next to the address. Users can view a list of their contacts with this problem but as a Salesforce Manager could I get a report of all email addresses that have this problem?

Thanks

In the Spring '09 release, it was announced "a new release of the Eclipse plug-in for Force.com that will contain Apex Editor code assistance".
I have the latest IDE release (19) but I can't get it with "Ctrl + space"
Does anyone have the "apex assistance" working?

 

In the Spring '09 release, it was announced "a new release of the Eclipse plug-in for Force.com that will contain Apex Editor code assistance".
I have the latest IDE release (19) but I can't get it with "Ctrl + space"
Does anyone have the "apex assistance" working?

 

Thanks


    Is there any way to restart  an autonumber field in a Custom Object??

    I can't change the type of my field because I use it in a trigger

     

    I need Help!!!! I have some problems with my Test Method  

     

     

    • My VF Page: I have several fields which i need to create them as "required" using "Error messages".  Here is an example:

     

     

     

    <apex:pageBlockSectionItem id="BSI_Status">
     <apex:outputLabel value="Estatus" for="estatuspicklist" />
     <apex:outputPanel styleClass="requiredInput" layout="block">  
      <apex:outputPanel styleClass="requiredBlock" layout="block"/>
      <apex:selectList value="{!caso.Status}" multiselect="false" size="1" id="estatuspicklist">
        <apex:selectOption itemValue="" itemLabel="" />
          <apex:selectOption itemValue="Abierto" itemLabel="Abierto" />
          <apex:selectOption itemValue="Cerrado" itemLabel="Cerrado" />
          <apex:selectOption itemValue="Cancelado por error" itemLabel="Cancelado por error" />
        </apex:selectList>
      <apex:outputPanel styleClass="errorMsg" layout="block" rendered="{!errorEstatus}">
        <strong>Error: </strong>{!errorMessage}</apex:outputPanel>
      </apex:outputPanel>
    </apex:pageBlockSectionItem>

     

    • My Controller:  When the user clic on "Save" button, I make a validation on the class, if the field is empty, the error is activated, if not the record is saved.
    	public PageReference guardar()
    		{
    		if(caso.Status == '' || caso.Status == null) errorEstatus = true;  else errorEstatus = false; 
    		if(caso.SUI_Departamento__c != 'Otro' && (servicio == '' || servicio == null || servicio == ID_OTRO)) errorServicio = true;  else  errorServicio = false;
    		if(caso.SUI_Departamento__c == 'Otro' && (caso.SUI_Area__c == '' || caso.SUI_Area__c == null)) errorArea = true; else  errorArea = false;
    		if(caso.SUI_Departamento__c == 'Otro' && (caso.SUI_OtroServicio__c == '' || caso.SUI_OtroServicio__c == null)) errorDesc = true;  else errorDesc = false;  
    		if((caso.SUI_QuienSolicita__c == 'Departamento Interno' || caso.SUI_QuienSolicita__c == 'Organismo externo') && (caso.SUI_Solicitante__c == '' || caso.SUI_Solicitante__c == null)) errorSolic = true; else errorSolic = false;
    		
    		if(errorEstatus == false && errorServicio == false && errorArea == false && errorDesc == false && errorSolic == false)
    		{
    		try { GuardaCaso(); }
    	 	catch (Dmlexception e)
    			{
    			ApexPages.addMessages(e);	
       		return null;
    			}
    			String retUrl = Apexpages.currentPage().getParameters().get('retURL');
    			if(retUrl=='' || retUrl==null) retUrl='/500/o';
    			Pagereference ref = new Pagereference(retUrl);
        	ref.setRedirect(true);
        	return ref;
    		}
    		else return null; 
    	}

     

     

    The problem is that no matter what I do in my test, I can't make to execute the "If" lines

     

    I Have tried this:

     

     

    	  
              
              Case c = new Case(AccountId = ID_CUENTA, ContactId = contacto.Id, Description = 'Prueba', RecordTypeId= '0124000000013PGAAY'); 
    				
    	  ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(c);
    	  CONTROL_CasoTramite controller = new CONTROL_CasoTramite(sc);	
    	  Test.setCurrentPage(new PageReference('/apex/CasT'));
    	  
    	  test.startTest();
    	  controller.getCaso();
    	  controller.caso.Status = '';
    	  controller.caso.SUI_Departamento__c = 'CIAC';
    	  controller.servicio = '';
    	  controller.guardar();
    	  Test.stopTest();
                  
    

     

    Even I tried to put an System.Debug to print the values of controller.caso.Status, controller.caso.SUI_Departamento__c and controller.servicio, and they have values but my test doesn't work in the red lines

     

     Please any idea!!!!

     

     

     

    I need your help. I've a subquery and Im' trying to display it in a visualforce page without any results:

     

    My Class:

     

     

    	public List<SObject> getOpen()
    		{
    	
    		SObject[] Cuenta = [SELECT Name, 
    		         (Select Subject, WhoId, WhatId, Id, IsTask, ActivityDate, Status, Priority, OwnerId FROM OpenActivities  
    		          WHERE OwnerID =:USER_ID ORDER BY ActivityDate ) 
    		          From Account WHERE id=:RECORD_ID];
    		Actividades = Cuenta.get(0).getSObjects('OpenActivities'); 
                    //This is just to verify the Actividades list
    		for(Integer i=0; i<Actividades.size(); i++)
    			{
    			System.debug('********Sobject'+Actividades[i]);
    			}
    		return Actividades;
    		}		

     

    In my page I want to display the Subject, WhoId, WhatId, etc.

     

    If I put:

     

     

    	<apex:pageBlock title="Actividades Abiertas" >    
    		<apex:dataTable value="{!Open}" var="each" cellpadding="10" border="0" styleClass="list">
    			<apex:column headerValue="Acción">{!each}</apex:column>
    	</apex:pageBlock>

     

     

    I have my 5 id's open activities without a problem.  But if I put:

     

     

    	<apex:pageBlock title="Actividades Abiertas" >    
    		<apex:dataTable value="{!Open}" var="each" cellpadding="10" border="0" styleClass="list">
    			<apex:column headerValue="Acción">{!each.Subject}</apex:column>
    	</apex:pageBlock>

     

     

    I've got an error ' SObject.Subject Property Unknown'

     

    In my debug log I have my list with all the data

     

     

    11:10:0.928|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{Status=No iniciada, AccountId=001R000000QAo87IAD, WhatId=001R000000QAo87IAD, Subject=Llamada, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=true, Id=00TR0000008DY1OMAW, ActivityDate=2010-04-09 00:00:00, Priority=Normal}
    
    11:10:0.931|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{Status=No iniciada, AccountId=001R000000QAo87IAD, WhatId=a0BR0000002ppkaMAA, Subject=Enviar Encuesta, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=true, Id=00TR0000008DiZNMA0, ActivityDate=2010-04-26 00:00:00, Priority=Normal}
    
    11:10:0.933|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{Status=No iniciada, AccountId=001R000000QAo87IAD, WhatId=001R000000QAo87IAD, Subject=Generar Reporte, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=true, Id=00TR0000008DY2nMAG, ActivityDate=2010-04-28 00:00:00, Priority=Normal}
    
    11:10:0.936|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{AccountId=001R000000QAo87IAD, WhatId=a0BR0000002ppkaMAA, Subject=Reunión, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=false, Id=00UR0000004Y5fYMAS, ActivityDate=2010-07-20 00:00:00}
    
    11:10:0.939|USER_DEBUG|[44,4]|DEBUG|********SobjectOpenActivity:{AccountId=001R000000QAo87IAD, WhatId=001R000000QAo87IAD, Subject=Reunion, WhoId=003R000000MurqIIAR, OwnerId=005400000010CwqAAE, IsTask=false, Id=00UR0000004Y5cFMAS, ActivityDate=2010-10-19 00:00:00}
    

     

     

     

     

    I need your help, I'm overriding the "New" and "Edit" button of Accounts deppending of the profile of the user.

    For some profiles there will be showed x page (I'have developed that and that's ok) but the problem is when I want for some users to show the standard "new" or "edit" salesforce page.  How do I get that!!??

     

    I use this code to show x page (I don't have problems here)

     

     

    if (USER_PROFILE == '00e40000000wksvAAA') { PageReference PageRef= new PageReference('/apex/pagex'); PageRef.setredirect(true); PageRef.getParameters().put('id', ID); return pageRef; }

     

     I use this other when a user doesn't have access to this option (I don't have problems here)

     

     

    else return null;

     

     What do i need do if I want that certain profile goes to the standard salesforce page to add or edit a record???

     

     

     

    I need to send a SMS from a list of contacts in SF... The idea is: make a report with some criterias and send to all this people a SMS, and save a task in each record that says it was sended the SMS

     

    Have anybody made something like this??

    How do you render a subquery from a custom list controller?  I want to render fields from ActivityHistories for the current account.  ***I also need to have pagination.***

     

    Thanks

     

    Here is my current code:

     

     

    public class ActivityHistorySetConExt {
    
            //ApexPages.StandardSetController must be instantiated for standard list controllers
     
            public ApexPages.StandardSetController setCon {
            get {
                if(setCon == null) {
                    setCon = new ApexPages.StandardSetController(
                    	Database.getQueryLocator(
                          	[select id, name, ownerid,
    							(select subject, whoid, whatid, accountid, ownerid, activitydate, description from ActivityHistories 
    							 order by activitydate desc
    							 limit 1000)
    						from account
    						where id = :ApexPages.currentPage().getParameters().get('id')]
                          )
    				);
                }
                //setCon.SetPageSize(5);
                return setCon;
            }
            set;
        }
        
        // Initialize setCon and return a list of records  
        
        public List<Account> getAccounts() {
             return (List<Account>) setCon.getRecords();
        }
        
        // returns the next page of records
     	public void first() {
     		setCon.first();
     	}
     	
     	// returns the next page of records
     	public void last() {
     		setCon.last();
     	}
        
        // indicates whether there are more records before the current page set.
    	public Boolean hasPrevious {
    		get {
    			return setCon.getHasPrevious();
    		}
    		set;
    	}
    	
    	// returns the previous page of records
     	public void previous() {
     		setCon.previous();
     	}
        
        // indicates whether there are more records after the current page set.
    	public Boolean hasNext {
    		get {
    			return setCon.getHasNext();
    		}
    		set;
    	}
    	
    	// returns the next page of records
     	public void next() {
     		setCon.next();
     	}
        
    }

     

     

     

    I thought this was a new feature of Salesforce but I can't seem to find it. Is there a way to show a running total of a field across all records when looking at the related list for that object?

     

    For example, show a total of the Invoice RME Requested column in the footer of the related list below?

     

    RME

    RMEs

    RMEs Help RMEs Help (New Window)
    ActionRME: RME NameInvoice RME RequestedFee RME RequestedPricing RME RequestedLock Extension RMEGranted Amt
    Edit | Del0810 Certified Federal$325.00$0.00$0.00$0.00 
    Edit | Del0810 Cole Taylor$1,250.00$0.00$0.00$0.00 
    Edit | Del0810 Cole Taylor2 $0.00$744.47$0.00$744.47
    Edit | Del0810 Affinity $0.00$0.00$137.93$137.93
    Edit | Del0810 Santa Cruz $250.00$0.00$0.00 

    Have A Commission Rate Object:

    Sales-$  Rate

    1            10%

    2            12%

    3            14%

    4            16%

    * Oversimplified version - it will actual start at .01 and go throught 9,999.99

     

    Want to link it to the Opportunity Object.  So if Sales are $2,  Rate = 12%.  Is there a better way to do this other than creating a  a look field based on the Sales-$?

    Is there any way to restart  an autonumber field in a Custom Object??

    I can't change the type of my field because I use it in a trigger

     

    I need Help!!!! I have some problems with my Test Method  

     

     

    • My VF Page: I have several fields which i need to create them as "required" using "Error messages".  Here is an example:

     

     

     

    <apex:pageBlockSectionItem id="BSI_Status">
     <apex:outputLabel value="Estatus" for="estatuspicklist" />
     <apex:outputPanel styleClass="requiredInput" layout="block">  
      <apex:outputPanel styleClass="requiredBlock" layout="block"/>
      <apex:selectList value="{!caso.Status}" multiselect="false" size="1" id="estatuspicklist">
        <apex:selectOption itemValue="" itemLabel="" />
          <apex:selectOption itemValue="Abierto" itemLabel="Abierto" />
          <apex:selectOption itemValue="Cerrado" itemLabel="Cerrado" />
          <apex:selectOption itemValue="Cancelado por error" itemLabel="Cancelado por error" />
        </apex:selectList>
      <apex:outputPanel styleClass="errorMsg" layout="block" rendered="{!errorEstatus}">
        <strong>Error: </strong>{!errorMessage}</apex:outputPanel>
      </apex:outputPanel>
    </apex:pageBlockSectionItem>

     

    • My Controller:  When the user clic on "Save" button, I make a validation on the class, if the field is empty, the error is activated, if not the record is saved.
    	public PageReference guardar()
    		{
    		if(caso.Status == '' || caso.Status == null) errorEstatus = true;  else errorEstatus = false; 
    		if(caso.SUI_Departamento__c != 'Otro' && (servicio == '' || servicio == null || servicio == ID_OTRO)) errorServicio = true;  else  errorServicio = false;
    		if(caso.SUI_Departamento__c == 'Otro' && (caso.SUI_Area__c == '' || caso.SUI_Area__c == null)) errorArea = true; else  errorArea = false;
    		if(caso.SUI_Departamento__c == 'Otro' && (caso.SUI_OtroServicio__c == '' || caso.SUI_OtroServicio__c == null)) errorDesc = true;  else errorDesc = false;  
    		if((caso.SUI_QuienSolicita__c == 'Departamento Interno' || caso.SUI_QuienSolicita__c == 'Organismo externo') && (caso.SUI_Solicitante__c == '' || caso.SUI_Solicitante__c == null)) errorSolic = true; else errorSolic = false;
    		
    		if(errorEstatus == false && errorServicio == false && errorArea == false && errorDesc == false && errorSolic == false)
    		{
    		try { GuardaCaso(); }
    	 	catch (Dmlexception e)
    			{
    			ApexPages.addMessages(e);	
       		return null;
    			}
    			String retUrl = Apexpages.currentPage().getParameters().get('retURL');
    			if(retUrl=='' || retUrl==null) retUrl='/500/o';
    			Pagereference ref = new Pagereference(retUrl);
        	ref.setRedirect(true);
        	return ref;
    		}
    		else return null; 
    	}

     

     

    The problem is that no matter what I do in my test, I can't make to execute the "If" lines

     

    I Have tried this:

     

     

    	  
              
              Case c = new Case(AccountId = ID_CUENTA, ContactId = contacto.Id, Description = 'Prueba', RecordTypeId= '0124000000013PGAAY'); 
    				
    	  ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(c);
    	  CONTROL_CasoTramite controller = new CONTROL_CasoTramite(sc);	
    	  Test.setCurrentPage(new PageReference('/apex/CasT'));
    	  
    	  test.startTest();
    	  controller.getCaso();
    	  controller.caso.Status = '';
    	  controller.caso.SUI_Departamento__c = 'CIAC';
    	  controller.servicio = '';
    	  controller.guardar();
    	  Test.stopTest();
                  
    

     

    Even I tried to put an System.Debug to print the values of controller.caso.Status, controller.caso.SUI_Departamento__c and controller.servicio, and they have values but my test doesn't work in the red lines

     

     Please any idea!!!!

     

     

     

    Hi,

     

    when i click on any of the account listed, it should navigate to that particular account page. Currently, when i click on any of the account, the page gets refreshed and remains in the same place. Can any one tell me how this can be achived. Here is the VF'code,

     

    <apex:page standardController="Account" recordSetVar="accounts">
     <apex:pageBlock title="Viewing Accounts">
      <apex:form id="theForm">
       <apex:pageBlockSection>
        <apex:dataList value="{!accounts}" var="a" type="1">                <apex:commandLink>{!a.name} </apex:commandLink>
        </apex:dataList>
       </apex:pageBlockSection> 
       <apex:panelGrid columns="4">
         <apex:commandLink action="{!first}">First</apex:commandLink>
         <apex:commandLink action="{!previous}">Previous</apex:commandLink>
         <apex:commandLink action="{!next}">Next</apex:commandLink>
         <apex:commandLink action="{!last}">Last</apex:commandLink>
       </apex:panelGrid>
      </apex:form>
     </apex:pageBlock>  
    </apex:page>

     

    Thanks.

    • August 18, 2010
    • Like
    • 0

    Here's my 'problem' -

     

    I'm not new to programming, but I'm quite new to Salesforce and Apex. My programming experience lies mainly in C++ and VB.

     

    I'd like to create a custom button to replace the standard 'Save' button for a custom object. I have an object that is used as a schedule, each record of this object type is one shift, on one day, for one employee. With over 100 employees, there are a lot of shifts to enter. I find that it will save a LOT of time if users can enter multiple shifts at once, and I see an opportunity for this when the only thing that changes between two shifts is the date by an increment of one day. Lots of employees work in the same department at the same hours, 5 days in a row.

     

    Ideally the button would make these almost identical shifts easier to enter. I'll create a field where the user can enter how many consecutive days the shift will be happening and they'll enter the start date. The default for the field for consecutive days will always "1", so that unless changed, a single record will be created. If the user enters 5, I want 5 total records to be created, the first will start on the "start date" and each record thereafter will start one day later.

     

    Example: Start Date = 10/1/10

    Consecutive Days: 3

     

    Should create three records, all the other fields on the record the same, and the dates being 10/1/10, 10/2/10 and 10/3/10.

     

    Like I said, I'm really knew to Salesforce and Apex, so something somewhat detailed would be great. Thanks!

    I have an embedded VF page that links the user to an external website.

     

    Only users in a specific profile can access this embedded site.

     

    I have two pageblock sections on the VF Page.  Only one of them gets rendered. 

     

    When the user should not see the embedded website I want to change the height of VF page so that I do not have excess white space.

     

    When I add the VF Page to the page layout I set the height in pixels.  Can I change that height when the page is rendered?

     

    Any help is appreciated.

     

    Thanks

     

    Mike

    • May 19, 2010
    • Like
    • 0

    Hi, I need help in developing a custom formula field that calculates the Age from a given date, in terms of years and months, like this:

     

    MyDate: 18/05/1990  (dd/mm/yyyy)

     

    Calculated Age: 19 year(s), 11 month(s)

     

    I have tried several formulas, but I only could get the year and I got problems with the months calculation.

     

    Could someone help with this?

     

    Regards,

     

    Wilmer

    Alright, after reading trough a lot of board message i fininally give up and ask 4 help

     

    My reps do these actions a lot and i'm trying to combine them into 1 button to expedite things:

     

    Steps:

     

    1-change the Lead status to: Sent info and save

    2-Send a specif email template (DONE)

    3-add to Specif campaign called "info email"  and save

     

    now i finally got step 2 done in a button already  (https://na2.salesforce.com/_ui/core/email/author/EmailAuthor?p2_lkid={!Lead.Id}&rtype=00Q&template_id=00X400000017659&save=X&retURL=%2F{!Lead.Id}&saveURL=%2F{!Lead.Id})    and it works properly now i'm tryng to add the other two steps into the same button and this is where i'm statrting to get lost

     

    if somebody could help or at least let me know if even possible i would appreciate.

     

     

    Lead Status Id: 00N40000001esp6

    Campaign Id (info Email): 70140000000G6Ol

     

     

     

    • April 27, 2010
    • Like
    • 0

    I'm trying to create a custom button that will auto-select the From address when sending an email from a case, depending on a custom field on the case record.  I've tried several ways of doing this, but none of them seem to be working correctly.  One of the posts I found on the board uses Javascript to hack the URL, and I've tried doing this, but I get the error "unexpected token ILLEGAL" when I try it.  Here's the code I'm using:

     

    IF({!Case.CustomField__c} = 'Option 1', location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId}&p26=address1@gmail.com;, 

    (IF({!Case.CustomField__c}='Option 2', location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId}&p26=address2@gmail.com;, 

    location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId};)))

     

    I imagine I'm doing this wrong, since this seems to be mixing Salesforce formulas with Javascript.  Is this the correct way to approach my issue, or is there a way to make the button link to the desired URL without using Javascript?

    Folks.. I'm thinking my question is fairly basic.

     

    I have a custom date field. I am trying to create a validation rule that won't allow end users to edit the record IF this particular date field has been filled in. If the field is NULL, then end users can continue to make edits.

     

    Lastly, IF the field has been completed - there are two User Profiles that can continue to make edits. I think I'm close, but not quite there yet. Here's what I've come up with so far:

     

    AND(
    Uploaded_in_AIS__c <> null
    ,AND($Profile.Name <> "System Administrator",$Profile.Name <> "Manager")
    )

     

    Help is much appreciated! Thanks

    Hi,

     

    I have this query in my apex class:

    actvty= [ SELECT (SELECT ActivityDate, Description,Subject,who.name from ActivityHistories order by ActivityDate desc ) FROM Contact WHERE Id in :contid]; return actvty;

    I am not sure how do I display this result in Visual force page. I tried the follwing but give me error.(Error: Invalid field Subject for SObject Contact)

    <apex:pageBlockTable value="{!actvty}" var="t" rendered="{!NOT(ISNULL(actvty))}" > <apex:column value="{!t.Subject}"/> <apex:column value="{!t.Who.Name}"/> <apex:column value="{!t.ActivityDate}"/> </apex:pageBlockTable> <apex:outputLabel value="No records to display" rendered="{!(ISNULL(actvty))}" styleClass="noRowsHeader"></apex:outputLabel> </apex:pageblock>

     

    Could you please help me ?

     

    Message Edited by das on 08-03-2009 04:11 PM
    Message Edited by das on 08-05-2009 03:47 PM

    Is there a reason I cannot have a custom button display in a new window without having to write JavaScript for it to happen?  Is there a workaround for this? My users would like to be able to view the page they are on and have another window open when they click on the list button.

     

    I have a created a custom List button containing a visualforce page and want to display it in a separate window from the page that is already on display.

     

    Any suggestions?

    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
    Hi All,

    i need to display related list of opportunities on visual force page with "created date" field. I am using Account as StandardController for the page.
    My issue is regarding the format of CreatedDate field, by default it shows the value with time stamp but the desired format is 'dd/mm/yyyy'.
    how can i change its format on Visual force page directly.


    Thanks
    Ajit Verma