You need to sign in to do that
Don't have an account?

How to find line break in middle of long text area field.
I am having a long text area field which has long information.
I am trying get one middle line,which is like this.
xxxxxxx
xxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx
salesforce office:Working hours
XXXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
So i want to get everything after 'salesforce office: '
output in this case= 'working hours' This is dynamic value.
and save that it another text field.I am able to get that everything after office: but its not recognizing line break.
thats were i am struck..I am having other reasons to use apex trigger.So workflow or Builder doesnt work for me.
Any help?Thanks!!
I am trying get one middle line,which is like this.
xxxxxxx
xxxxxxxx
xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx
salesforce office:Working hours
XXXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
So i want to get everything after 'salesforce office: '
output in this case= 'working hours' This is dynamic value.
and save that it another text field.I am able to get that everything after office: but its not recognizing line break.
thats were i am struck..I am having other reasons to use apex trigger.So workflow or Builder doesnt work for me.
Any help?Thanks!!
String cd=Longtextareafield.substring(Longtextareafield.indexof('office:')+8);
List<String> ln=cd.split('\r\n');
i was using \n and \\n which didnt work .Thank you.
All Answers
myInput.split('\n');
Here is a trick.
1) Create a Custom Label called line_break : "-" (new line) "-"
2) Create a first formula field replacing all these $Label.line_break (without "-") with "<BR>"
myField1 = salesforce office:Working hours
XXXXXXXXXXXXXX
XXXXXXXXXXXXX
XXXXXXXXXXXXXXXX
myFieldFormula1 = SUBSTITUTE( myField1,SUBSTITUTE($Label.line_break, "-", ""),"<BR>")
Result:
myFieldFormula1 = salesforce office:Working hours<BR>XXXXXXXXXXXXXX<BR>XXXXXXXXXXXXX<BR>XXXXXXXXXXXXXXXX
3) Create a second formula field which uses the first formula field with CONTAINS, FIND, LEFT and SUBSTITUTE(text, old_text, new_text).
myFieldFormula2 = SUBSTITUTE(IF(CONTAINS( myFieldFormula1 , '<BR>'), LEFT(myFieldFormula1 , FIND('<BR>', myFieldFormula1 )-1), myFieldFormula1 ),"salesforce office:","")
So i am looking for something which can fix my apex trigger.
thank you!!
String [] lines = myInput.split('\n');
I want to get only this part and save in a string.
WORKING HOURS
nothing before and after has to come.How can i get that in apex trigger.
salesforce office:Working hours
String [] lines = myInput.split('\n');
String firstLine = lines[0];
String [] before_after_colon = firstLine.split(':');
String before_colon = before_after_colon [0].trim(); // useless here
String after_colon = before_after_colon [1].trim(); // without spaces
System.debug('afer colon:' + after_colon);
System.debug('before colon:' + before_colon);
String cd=Longtextareafield.substring(Longtextareafield.indexof('office:')+8);
List<String> ln=cd.split('\r\n');
i was using \n and \\n which didnt work .Thank you.