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
AbAb 

Displaying a text field in two lines

Hello,

I have a vf code like below
<apex:outputText value="{!caseObj.Asset.SerialNumber}"/>
Serial number is a standard field Text(80)

I want to disply first 8 characters on one line and the rest characters on other line, like below
 
A0123456
789105SDFDS

How can i achieve it with minimal code.

thanks for suggestions
 
Best Answer chosen by Ab
Nisar799Nisar799
Hi Sandrine,

Here you go with the VF page code to meet your goal of showing Serial Number in two lines, first 8 character on line 1 and remaining on line 2.
 
<apex:outputText value="{0}{1}" escape="false">
      <apex:param value="{!LEFT(caseObj.Asset.SerialNumber, 8)}"/>
      <apex:param value="{!IF(LEN(caseObj.Asset.SerialNumber) > 8,'<br/>'+RIGHT(caseObj.Asset.SerialNumber, LEN(caseObj.Asset.SerialNumber)-8),'')}"/>
</apex:outputText>

I Hope that will solve your issue.
Best Regards
799 The Coder

All Answers

Sumeet_ForceSumeet_Force
Either of following:
1. Create 2 formula fields and  show them on the page.
2. Create controller to fetch the data via apex and split it into 2 using 2 variables exposed and linked on the page.
AbAb

Hello Sumeet,

Thank you for reply.
I cannot create new formula field.
Is it possible to realize my usecase directly by manipulating in VF only without using controller

Sumeet_ForceSumeet_Force
Certain formula conditions are allowed in VF itself. So you can try using substring functions twice in the page to get the result you need. If that doesnt work, I would say, try javascript on the VF.
Nisar799Nisar799
Hi Sandrine,

Here you go with the VF page code to meet your goal of showing Serial Number in two lines, first 8 character on line 1 and remaining on line 2.
 
<apex:outputText value="{0}{1}" escape="false">
      <apex:param value="{!LEFT(caseObj.Asset.SerialNumber, 8)}"/>
      <apex:param value="{!IF(LEN(caseObj.Asset.SerialNumber) > 8,'<br/>'+RIGHT(caseObj.Asset.SerialNumber, LEN(caseObj.Asset.SerialNumber)-8),'')}"/>
</apex:outputText>

I Hope that will solve your issue.
Best Regards
799 The Coder
This was selected as the best answer