0

I have a rich area text field that I need to be able to trim using a formula so that I can display the first line of text from it.

For example, this is what the text field looks like:

TEST TEXT 1, TEST TEXT 2, TEST TEXT 3, ETC,.

I need to be able to take that first line (TEST TEXT 1) before the comma and display only that text in a normal text field, I tried using a combination of find, trim, and left in my formula but it didn't produce the desired result. Anyone have any idea how to accomplish this?

1 Answer 1

1

I am not sure if you can do this :

Rich text area fields cannot be used in a formula. They can be used in validation rules and workflow rules.

See link bellow Unable to create a formula field that has a rich text area field .

So you need to go either with Apex Trigger or Workflow Field update( not sure if you can do it with this one ).

So I would suggest to go with simple Before Insert/Update trigger.

Trigger would look like this :

trigger AccountTriggerFor on Account (before insert, before update) {
  if(Trigger.isInsert) {
      for(Account acc: Trigger.New) {
          if(acc.Long_Area_field__c != null) {
              String temp = acc.Long_Area_field__c;
              // do logic 
              acc.Some_text__c = temp;
          }
      }
  }
  if(Trigger.isUpdate) {
      for(Account acc: Trigger.New) {
          if(acc.Long_Area_field__c != Trigger.newMap.get(acc.Id).Long_Area_field__c) {
              String temp = acc.Long_Area_field__c;
              // do logic 
              acc.Some_text__c = temp;
          }
      }
  } 
}

Of course you can write Handler Class and so on...

2
  • Would it be possible with a long area text? I have another field that pulls in that value from a picklist as well. Jan 31, 2022 at 17:25
  • @EdwardSobotka you can not use long text area field either. Check this : help.salesforce.com/s/… Jan 31, 2022 at 17:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .