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
Sandrine94748Sandrine94748 

Display text based on condition and in hyperlink

Hello,

I want to achieve two things in my formula:

1) Based on condition display text
2) Display that text in hyperlink

For example the algo is like

If(customField__C = 'PQR')
  Then Display/text value is TT-PPQR
Else if(customField2__c == 'ERT')
  Then Display/text value is TT-ERT
Else
  Display/text value is ZZR

I wantt o diplay them as hyperlink like when they click on them it should redirect them to www.ZZR.co.fr website
just an example

thanks for suggestion !

Best Answer chosen by Sandrine94748
Akshay_DhimanAkshay_Dhiman
Hi Kiran,

As You asked that whenever you enter the value in a particular textbox , the value should be updated with the prefix 'TT-'. So for the same , i have made the trigger on the custom field (Label Name - Custom Field) that will update the field with the prefix you want to add.
In addition to it , you want the hyperlink for the same textbox . This cannot be possible . Alternatively , you can create another custom field (URL TYPE) , and get updated on the other text field On which trigger is updating the value. In that url you can provide any url you want to give.

Here is a complete code :

Apex Class Code - >
 
public class UpdateContactCustomField {
    public static void  fieldupdate(List <Contact> ContactList){
       for(Contact con : ContactList)
    	{
            if(con.Custom_Field__c != null){
                con.Custom_Field__c = 'TT-'+ con.Custom_Field__c;
            }  		
    	}   
     }
}
Apex trigger - >
trigger UpdateContactCustomFieldTrigger on Contact (before insert ,before update) {
    if(Trigger.isbefore && Trigger.isinsert){
        UpdateContactCustomField.fieldupdate(Trigger.new);    
    }
    else if(Trigger.isbefore && Trigger.isupdate){
        UpdateContactCustomField.fieldupdate(Trigger.new);  
    }
}

For the Formula field please check the screenshots.

User-added image
User-added image


Regards,
Akshay