function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hylim1215hylim1215 

how do i use line break in my IF statement result?

Hi, I have a custom repeat list and one of the column will display different result based on certain condition:-
 
<apex:repeat value="{!Quote.QuoteLineItems}" var="qli">
                        <tr class = "stdstyle">
                            <td>{!FLOOR(count)} </td> 
                            <td>{!qli.Product2.Name}</td>
                            <td >{!IF(qli.Quote_PDS_Description__c == "Summary Only",qli.Product_Description__c,IF(qli.Quote_PDS_Description__c == "Summary & Short Details",qli.Product_Description__c +  qli.Quote_attribute_1__c ,""))} </td>
                            <td>{!qli.UnitPrice}</td>
                                
                            <apex:variable var="count" value="{!count+ 1}"/>
                        </tr>
                    </apex:repeat>
as you see from the above, i would like to have a line break between Product_Description__c & Quote_attribute_1__c instead of joining them together in 1 line. Is that possible?

Thanks.
 
Best Answer chosen by hylim1215
Tavva Sai KrishnaTavva Sai Krishna
Hi hylim,

Try below code.
 
{!qli.Product_Description__c} {!IF(qli.Quote_attribute_1__c == null,'','<br/>')}
{!qli.Quote_attribute_1__c} {!IF(qli.Quote_attribute_2__c == null,'','<br/>')}
{!qli.Quote_attribute_2__c} {!IF(qli.Quote_attribute_3__c == null,'','<br/>')}
{!qli.Quote_attribute_3__c} {!IF(qli.Quote_attribute_4__c == null,'','<br/>')}
{!qli.Quote_attribute_4__c} {!IF(qli.Quote_attribute_5__c == null,'','<br/>')}
{!qli.Quote_attribute_5__c} {!IF(qli.Quote_attribute_6__c == null,'','<br/>')}
{!qli.Quote_attribute_6__c}

Let me know if you face any issues, alternatevely mark the best answer if this answers your question.

Regards,
Sai Krishna Tavva.

All Answers

Tavva Sai KrishnaTavva Sai Krishna
Hi hylim1215,

You can use the html break tag to give line break. copy the modified code.
 
<apex:repeat value="{!Quote.QuoteLineItems}" var="qli">
                        <tr class = "stdstyle">
                            <td>{!FLOOR(count)} </td> 
                            <td>{!qli.Product2.Name}</td>
                            <td >{!IF(qli.Quote_PDS_Description__c == "Summary Only",qli.Product_Description__c,IF(qli.Quote_PDS_Description__c == "Summary & Short Details",qli.Product_Description__c +'</br>'+  qli.Quote_attribute_1__c ,""))} </td>
                            <td>{!qli.UnitPrice}</td>
                                
                            <apex:variable var="count" value="{!count+ 1}"/>
                        </tr>
                    </apex:repeat>

let me know if any errors you face. Alternatevely if this solution gives answer to your question ,please mark it as a best answer.

Regards,
Sai Krishna Tavva.
 
hylim1215hylim1215
Hi Tavva,

adding this '</br>' will display this html tag as a text in my pdf, it doesnt break the line.

without ' ' will give me error.

Thanks.
Tavva Sai KrishnaTavva Sai Krishna
Hi hylim,

Try updated code.
 
<apex:repeat value="{!Quote.QuoteLineItems}" var="qli">
	<tr class = "stdstyle">
		<td>{!FLOOR(count)} </td> 
		<td>{!qli.Product2.Name}</td>
		<td >
		<apex:outputPanel rendered = " {!IF(qli.Quote_PDS_Description__c == "Summary Only",true,false)}">
			{!qli.Product_Description__c}
		</apex:outputPanel>
		<apex:outputPanel rendered = " {!IF(qli.Quote_PDS_Description__c == "Summary & Short Details",true,false)}">
			{!qli.Product_Description__c} '<br/>' {!qli.Quote_attribute_1__c}
		</apex:outputPanel>		
		</td>
		<td>{!qli.UnitPrice}</td>
			
		<apex:variable var="count" value="{!count+ 1}"/>
	</tr>
</apex:repeat>

I have tried this in my DE Org. so let me know with the errors if you face any, 

Regards,
Sai Krishna Tavva.
hylim1215hylim1215
Hi Tavva,

How can I line break only when the attribute is not blank?

for example
{!qli.Product_Description__c} <br/>
{!qli.Quote_attribute_1__c} <br/>
{!qli.Quote_attribute_2__c} <br/>
{!qli.Quote_attribute_3__c} <br/>
{!qli.Quote_attribute_4__c} <br/>
{!qli.Quote_attribute_5__c} <br/>
{!qli.Quote_attribute_6__c} <br/>

that particular item do not have value on attribute 3~6 then it will leave a blank space in my PDF. how can br only when the attribute has value?

Thanks
Tavva Sai KrishnaTavva Sai Krishna
Hi hylim,

Try below code.
 
{!qli.Product_Description__c} {!IF(qli.Quote_attribute_1__c == null,'','<br/>')}
{!qli.Quote_attribute_1__c} {!IF(qli.Quote_attribute_2__c == null,'','<br/>')}
{!qli.Quote_attribute_2__c} {!IF(qli.Quote_attribute_3__c == null,'','<br/>')}
{!qli.Quote_attribute_3__c} {!IF(qli.Quote_attribute_4__c == null,'','<br/>')}
{!qli.Quote_attribute_4__c} {!IF(qli.Quote_attribute_5__c == null,'','<br/>')}
{!qli.Quote_attribute_5__c} {!IF(qli.Quote_attribute_6__c == null,'','<br/>')}
{!qli.Quote_attribute_6__c}

Let me know if you face any issues, alternatevely mark the best answer if this answers your question.

Regards,
Sai Krishna Tavva.
This was selected as the best answer