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.
- Code: Select all
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