+ Start a Discussion
studzeystudzey 

IF STATEMENT ON A VF PAGE

Hi Guys,


I got the following to work: 


<apex:OutputText value="{!IF(account.Use_Standard_WTC_Trading_Services__c,account.Standard_WTC_Account_Services_Provided__c,account.Services_Rendered_by_WTC__c)}"/>

The problem is that the text on the VF page, once display shows up all weird wiht <BR> and other items appearing in the text.

Can anyone explain how I can show the rich text fields properly? 

I tried the following 

<apex:OutputText value="{!IF(account.Use_Standard_WTC_Trading_Services__c,<apex:OutputText value="{!account.Standard_WTC_Account_Services_Provided__c"/>,<apex:OutputText value="{!account.Services_Rendered_by_WTC__c"/>)}"/>  but i seem to be getting an error the whole time!!! :(((

appreciate the help

Stadler
Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Your first version is basically right, but the HTML values are being escaped and rendered as text rather than markup.

 

outputfield version:

 

<apex:OutputField value="{!IF(account.Use_Standard_WTC_Trading_Services__c,account.Standard_WTC_Account_Services_Provided__c,account.Services_Rendered_by_WTC__c)}"/>

 

outputtext version:

 

<apex:OutputText escape="false" value="{!IF(account.Use_Standard_WTC_Trading_Services__c,account.Standard_WTC_Account_Services_Provided__c,account.Services_Rendered_by_WTC__c)}"/>

 

 

 

All Answers

bob_buzzardbob_buzzard

If you use outputfield rather than outputtext I'd expect the formatting to be preserved.  However, if you have to use outputtext, set the escape attribute to false (although be aware that this can present a security risk).

studzeystudzey

Thanks, 

 

Could you show me what the code should look like parhaps??

 

bob_buzzardbob_buzzard

Your first version is basically right, but the HTML values are being escaped and rendered as text rather than markup.

 

outputfield version:

 

<apex:OutputField value="{!IF(account.Use_Standard_WTC_Trading_Services__c,account.Standard_WTC_Account_Services_Provided__c,account.Services_Rendered_by_WTC__c)}"/>

 

outputtext version:

 

<apex:OutputText escape="false" value="{!IF(account.Use_Standard_WTC_Trading_Services__c,account.Standard_WTC_Account_Services_Provided__c,account.Services_Rendered_by_WTC__c)}"/>

 

 

 

This was selected as the best answer
studzeystudzey

Bob, on days like these I want to kiss ya

 

bob_buzzardbob_buzzard

That's one of the finest compliments I've been paid :)

studzeystudzey

Youre welcome bob! 

 

I was wondering if you could help me with the following: 

 

Is there a simple way to set up a workflow, to add a dynamic pdf attachment, stemming from the creation of a new record (custom object record). 

 

EG: 

 

Email saying: 

 

"Thanks for registering, please find your invoice attached" - the invoice is a document that contains particular information regarding that new record creation?

 

Looking forward to your reply, and appreciate your help

 

Stadler

 

bob_buzzardbob_buzzard

I'm not aware of any way to produce an email and attachments via workflow I'm afraid.  You could send the whole thing as a pdf using a visualforce template that renders as PDF, but I don't think you can mix the two.

studzeystudzey

OK Great, 

Yeah, I've managed to go for your option 2.

 

I have generated the following:

 

How do I then access the fields of the Event_Registration__c custom obect within the <messaging:plainTextEmailBody > section?

 

Thanks a mil

 

<messaging:emailTemplate subject="Official Invitation - World Trade Centers Associations (WTCA) Europe Africa Middle East (EMEA) Regio" recipientType="Contact" relatedToType="Event_Registration__c">
<messaging:plainTextEmailBody >

</messaging:plainTextEmailBody>

</messaging:emailTemplate>

bob_buzzardbob_buzzard

Actually, it looks like you can create an attachment in that way - check out this blog post (not mine!): 

 

http://salesforcetrekbin.blogspot.co.uk/2010/05/visualforce-email-template-with.html

studzeystudzey

Cant I just use the way that you said? I just need to be able to access the custom object fields from the Event_Registration__c custom object fields........

 

Thanks, checked out the post - interesting. I just don't want to develop classes at this time 

 

 

bob_buzzardbob_buzzard

Ah, okay.  I think you have to use {!related} or {!relatedTo} followed by the field name.  

studzeystudzey

Yep, just managed to sort it, thanks! :) 

 

How do i do the formatting in a visualforce email template?  I put everything inside an HTML block with <p></p> and <img> tags...but for some reason its just showing it in the email as i placed it in the HTML section?

 

 

bob_buzzardbob_buzzard

If they are inside the plaintextemailtemplate, you won't be able to format in that way, as the email client/page is told that it is plaintext and doesn't need parsing.

studzeystudzey

Thanks Bob, managed to get it sorted.

 

http://success.salesforce.com/questionDetail?qId=a1X30000000KmovEAC

 

I was wondering if I can take a look at this question for me? Much appreciated

 

Stadler