1

I m new in VF and i need some help

I trying to do an email , where the information that will appear in this email it depends from the value of one field, but it can have three possible options, imagine if the field value is equal to one it show on message in the email, if to "2" show anohter and if 3..., how can i manage this with thw visualforce condition.

THANKS YOU VERY MUCH IN ADVANCE

  • Are you using visualforce email template or just a visualforce with controller ?One can include logic in controller part as well as logic in view part of visualforce . – Mohith Shrivastava Nov 4 '13 at 11:00
  • welcome to community !Also could you please tell what have you tried so far – Mohith Shrivastava Nov 4 '13 at 11:01
  • I m just using the visual force controller, <p> <apex:outputtext value="{!{!Master_Application__c.Scholarship_Decision__c}}" render="{!if(ISNULL({!Master_Application__c.Scholarship_Decision__c}),false,true)}" </p> – Tomas Q. Nov 4 '13 at 11:06
  • please post controller code snippet to assist – Mohith Shrivastava Nov 4 '13 at 11:07
  • This field schoolarship decision have 4 options ("none", "30","40" "60") , and if its none in the template needs to appear some text, or if the choose any of the other option (in this case is 30, 40 60) it need to appear a different text – Tomas Q. Nov 4 '13 at 11:10
1
public  class Treeconditionhelper {

  public string displaytext{get;set;}
  public Id urlid;

  public Treeconditionhelper(){

   urlid=Apexpages.currentpage().getparameters().get('id');  

   //Assuming your query has fetched data here 
    Master_Application__c m=[Select Id,Interest_in_Merit_Scholarships__c,Scholarship_Decision__c from Master_Application__c  where id=:urlid]

      if(m.Scholarship_Decision__c=30 && m.Interest_in_Merit_Scholarships__c){
                 displaytext='text1';
        }else if(m.Scholarship_Decision__c=40 && m.Interest_in_Merit_Scholarships__c){
          displaytext='text2';
       }//..continue the pattern

  }


 }

visualforce code

<p> <apex:outputtext value="{!displaytext}‌​" </p>

The above pattern may help you to achieve what you looking for .I recommend going through visualforce guide and visualforce workbook to gain more expertise

http://www.salesforce.com/us/developer/docs/workbook_vf/

| improve this answer | |
1

This is the purpose of the Case function. See the complete list of visualforce functions for more information. Below is an example of using the case function to display either "Display One", "Display Two", or "Display Three" depending on the value of Master_Application__c.Scholarship_Decision__c.

<apex:outputText value="{!CASE(Master_Application__c.Scholarship_Decision__c, "Value1", "Display One", "Value2", "Display Two", "Default Value")}" />
| improve this answer | |

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.