+ Start a Discussion

Trigger - How to get a number in a rich text field

I have a RichTextField__c that contains text like below:

Dear FirstName,

Please see below for details:
Total: $1000  
<--- I need to get the number "1000" and save it to another custom field. 


Is there a way for me to get the total amount only "1000" and save it as the value of another custom field using a trigger?


Yes...If you are sure that other text is going to be mostly the same...then you can use some string functions smartly and get the value of 1000 easily. 1 of Quick ways to do:

1. Read entire string into variable.

2. find position of ONLY keyword and after AND keyword and remove all text before and after that.
3. This will keep just the 1000 there and then you can push it to the custom field.