Skip to main content
Anne Emerson ha fatto una domanda in #Salesforce Developer
I have a field set that includes a phone number (data type Phone) that is being used in a Visual Force page. The phone number formats correctly on my lightning pages ((000) 000-0000) but is just a number string when this field is displayed on my Visual Force page. 

 

Is there a way to remedy this so that the field set displays the phone format correctly? Do I need to make the phone number a formula text field instead of phone data type so that it will display correctly in my field set? If so, what formula would I use?
2 risposte
  1. 31 ago 2023, 11:19
    Hi Patricia Emerson,

    Visualforce and Classic UI will not perform any formatting when displaying value.

    You can refer below stackexchange link for the same:

    https://salesforce.stackexchange.com/questions/283558/apexoutputfield-not-formatting-phone-numbers-in-pdf

    You can create a new formula field with a Text return type and use below formula:

    "(" & LEFT(Phone__c, 3) & ") " & MID(Phone__c, 4, 3) & "-" & RIGHT(Phone__c, 4)

    Replace Phone__c with api name of Phone field used in vfpage.

    Add this created formula field to your field set and in your Visualforce page, use this formula field from the field set to display the formatted phone number like ((000) 000-0000).

    Related:

    https://www.youtube.com/watch?v=VoCaHpRejqc

    If this information helps, please mark the answer as best. Thank you

     
0/9000