Can't use getAsPlainText when running batch processor

Hi,
I urgently need some help.
I spent ages working on a solution that scans a folder for RTF files that need sending via email or fax.
When it finds an RTF file it finds the email or fax number in the RTF text and then sends that file as an attachment either via email or fax.
I was using the ‘getAsPlainText’ function on a RTF element on a form to get just the plain text and then parsing that for the bits of data I need.

	fv_txt_import = elements.fv_rtf_import.getAsPlainText ( );

	// find email address if there
	var lv_str_start = plugins.fmp.position ( fv_txt_import, 'Surgery Email', 1, 1 ) + 13;
	if ( lv_str_start <= 13 ) // no email tag
	{
		mail_email = '';
	}
	else
	{
		var lv_str_finish = plugins.fmp.position ( fv_txt_import, 'Date of Birth', 1, 1 );
		mail_email = plugins.fmp.trim (plugins.fmp.middle ( fv_txt_import, lv_str_start, ( lv_str_finish - lv_str_start ) ) );
	}

	// find fax no if there
	lv_str_start = plugins.fmp.position ( fv_txt_import, 'Surgery Fax', 1, 1 ) + 11;
	if ( lv_str_start <= 11 ) // no fax tag
	{
		mail_fax_no = '';
	}
	else
	{
		lv_str_finish = plugins.fmp.position ( fv_txt_import, 'Hospital No', 1, 1 );
		mail_fax_no = plugins.fmp.trim ( plugins.fmp.middle ( fv_txt_import, lv_str_start, ( lv_str_finish - lv_str_start ) ) );
	}

This all works beautifully in Smart Client, but the idea is to have it running on the Servoy server as a Batch Process.
Unfortunately when it runs as a batch process / headless client it appears that this function (getAsPlainText) does not work! :(
I assume that batch / HC cannot access form elements and therefore I just get ‘null’ returned and so my routine drops thru to the ‘fail’ part that sends an email to the admin saying it couldn’t find an email or fax no…
I hadn’t been able to test on the server as a batch process until today, having spent a long time getting my code right in Smart Client and using code from an another system that is working great as a batch process that handles LOTS of files, but obviously wasn’t using form elements.
My question is this…
Is there any way to get to the plain text version of an RTF field/column in Servoy using some other function? (or could Johan please add this as a new function in 5.2.3?)
or
does anyone have some cool JavaScript/RegEx that will let me pass it a complete RTF files text contents and return just the plain text from it? (I have Google’d and tried what I found to no avail)
Thanks,
Rafi

that’s right! in a batchprocessor you can’t use elements…
the batchprocessor has no GUI!

Harjo:
that’s right! in a batchprocessor you can’t use elements…
the batchprocessor has no GUI!

thanks for the confirmation, but now how do I get to the plain text of the RTF?

look here: viewtopic.php?f=3&t=11043&p=55118&hilit=plaintext#p55124

;-)

Harjo:
look here: viewtopic.php?f=3&t=11043&p=55118&hilit=plaintext#p55124

;-)

Harjo, I owe you a beer at ServoyWorld!!!
OMG, that did it, thank you (& Andrei) so much (at least it worked in smart client without using element)
Will now upload to client and see what happens :D

I just knew someone on the forums would have an answer…

rafig:
Harjo, I owe you a beer at ServoyWorld!!!

DEAL! :lol:

Harjo, it seems to be working on the Server as a batch process/HC, so thanks again!

Whilst I’m here, can I ask if anyone knows if it is possible to get the batch process/HC running on Servoy server to be able to access Windows network shares.
This system is currently picking up the files from a directory on the local C: drive and then moving them to another folder on C: drive once processed, but the client wants it to be able to pick them up from a network drive/share, which works fine in smart client, but not when running as service…

If not, they will have to set something up (another possible point of failure…) that moves them to server…

Thanks again,

Rafi

For those people wondering what about converting html formatted text:

var htmlEditorKit = new Packages.javax.swing.text.html.HTMLEditorKit();
   var htmlDocument = htmlEditorKit.createDefaultDocument();
   
   var reader = new java.io.StringReader('myHtmlTextString');
   htmlEditorKit.read(reader, htmlDocument, 0);
   
   var result =  htmlDocument.getText(0, htmlDocument.getLength());

   return utils.stringTrim(result));