# other way to do: elements.activitytext.getAsPlainText

**URL:** <https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477>\
**Category:** Classic Servoy\
**Created:** [August 19, 2008, 7:13pm UTC](https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477 "2008-08-19T19:13:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 19, 2008, 7:13pm UTC](https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477/1 "2008-08-19T19:13:15Z")

</div>

Is there an other way to do this:

```auto
var a = elements.activitytext.getAsPlainText();

```

this method is very handy to get the plainText of an RTF-field.

but now I have to do that in a calculation, in which I can’t touch elements, because they are simpy ‘not seen’

Anyone?

---

<div class="post-metadata">

**Author:** ![Andrei\_Costescu](https://avatars.discourse-cdn.com/v4/letter/a/e36b37/32.png) [@Andrei\_Costescu](https://forum.servoy.com/u/Andrei_Costescu)\
**Post date:** [August 20, 2008, 8:38am UTC](https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477/2 "2008-08-20T08:38:55Z")

</div>

Here is a way to bypass using the RTF Field for calculations:

```auto
var rtfEditorKit = new Packages.javax.swing.text.rtf.RTFEditorKit();
var rtfDocument = rtfEditorKit.createDefaultDocument();

var reader = new java.io.StringReader(my_rtf);
//rtfDocument.remove(0, rtfDocument.getLength());
rtfEditorKit.read(reader, rtfDocument, 0);	

globals.rtfcont = rtfDocument.getText(0, rtfDocument.getLength());

```

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [August 20, 2008, 1:12pm UTC](https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477/3 "2008-08-20T13:12:07Z")

</div>

wow! thank you! ![:D]( "Very Happy")  
that’ was exactly what I was looking for!

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 23, 2008, 7:41pm UTC](https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477/4 "2008-09-23T19:41:00Z")

</div>

Hi Andrei,

I’m now getting a nullpointer exception, in 3.5.7

```auto
Exceptie bij het uitvoeren van berekening: activitytext_plain van tabel activiti
es, fout org.mozilla.javascript.JavaScriptException: java.lang.NullPointerExcept
ion

```

with this calculation:

```auto
var rtfEditorKit = new Packages.javax.swing.text.rtf.RTFEditorKit();
var rtfDocument = rtfEditorKit.createDefaultDocument();

var reader = new java.io.StringReader(activitytext);
//rtfDocument.remove(0, rtfDocument.getLength());
rtfEditorKit.read(reader, rtfDocument, 0);   

return rtfDocument.getText(0, rtfDocument.getLength());

```

Can you tell me what I’m doing wrong here?

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [September 23, 2008, 7:50pm UTC](https://forum.servoy.com/t/other-way-to-do-elements-activitytext-getasplaintext/9477/5 "2008-09-23T19:50:34Z")

</div>

oke think I got it, i’m now first checking IF activity\_text contains a value!

here is my code:

```auto
if(activitytext) {
	var rtfEditorKit = new Packages.javax.swing.text.rtf.RTFEditorKit();
	var rtfDocument = rtfEditorKit.createDefaultDocument();
	
	var reader = new java.io.StringReader(activitytext);
	//rtfDocument.remove(0, rtfDocument.getLength());
	rtfEditorKit.read(reader, rtfDocument, 0);   
	
	return rtfDocument.getText(0, rtfDocument.getLength());
} else {
	return null
}

```

Now I get no errors ![:-)]( "Smile")
