+ Start a Discussion
nishanth0208nishanth0208 

Any way of accessing n th line(say 4th line) in a text area?

Hi All,

In the object i am currently working for, there is a text area. For that text area, i want to take the control over the 4th line(to use that text in another field). Can anyone suggest me how to do this?

Any method to pass the line number and get the text in the line?

 

Example:

BELOW IS MY TEXT IN TEXT FIELD.

----

text in line1

text in line2

text in line3

----

In the above context, i want to take control of text in line 2(text in line 2) and need to manipulate it and use for some purpose.

Please Suggest.

 

 

Thanks,

Krishna.

 

 

forcedotcomforcedotcom

Hi Krishna - this is a new one on me, I'll be interested to see what others suggest ... I'm fairly sure that you would need to do this through Apex code rather than it being something you can do via the UI. Can you give us some further detail on your requirement? What do you mean by 'take control of'?

Satya.KonaSatya.Kona

String.split() method may work..tried it qukcly on an apex class and triggered it to update a field on a different object.

below is the class and trigger...it fetches fourth line in description and updates that value as name of account.

let me know if this works and if this is wat u ar looking for...

 

 

public class TextVal{

public static void copyTextVal() {

Opportunity op = [select Description from opportunity where id= '00690000002Rpmm'];
String s = op.Description;
String[] sw = s.split('\n');

Account ac = [select name from account where id ='00190000003yEuQ'];
ac.name = sw[3];
update ac;
}
}

 

 

trigger trigTextVal on Opportunity (before update) {

for(opportunity o: Trigger.new) {
TextVal.copyTextVal();
}

}