On Mar 1, 2017, at 11:15 AM,Kirk Brooks wrote:

> In this case an record entry field sometimes has data pasted in from things
> like Word docs which can introduce a lot of extraneous crap. The user was
> looking for options to control that.

Pasting data from Word is problematic. Sometimes it works great and styles are 
preserved. Other times the resulting paste is a big mess. No easy fix. You need 
to get example Word documents that cause problems and then analyze the info in 
the pasteboard.

I ran into a similar problem and I had to put a button on the form called 
“Paste With No Style”. This would look at the data in the pasteboard, clean it 
up and remove stuff and then add it to the field. I added keyboard shortcut of 
Ctrl-Shift-V to the button for convenience. 

Here’ some sample code:

  // Paste With No Style button on Case Activity Notes input form

C_TEXT($theText_t)
C_LONGINT($start;$end)

$theText_t:=Get text from pasteboard
$theText_t:=ST Get plain text($theText_t)

GET HIGHLIGHT([CaseActivityNotes]Comments;$start;$end)

If (($start=1) & ($end=1))  // at the beginning of the field
   [CaseActivityNotes]Comments:=$theText_t+[CaseActivityNotes]Comments
Else   // somewhere else, so put it at the end
   [CaseActivityNotes]Comments:=[CaseActivityNotes]Comments+$theText_t
End if 

> Of course it also brought up issues of what happens to existing data when
> the option is toggled...

If you have a field that has styled text stored in it, and you turn off the 
Multi-style property on the form, you will just see all the span tags. 

For debugging purposes put 2 copies of the field on a form on top of each 
other. Turn on the Multi-style property on one, turn it off for the other. Set 
the non-Multi-style field to be “Invisible by Default". Then put an invisible 
button on the form with a secret keyboard shortcut only you know. Have the 
button toggle visibility of the 2 fields so that you can switch between 
“normal” Multi-style viewing and “raw” viewing so you can see all the span 
tags. 

This is very useful for tracking down and fixing unescaped characters like “&”, 
“<“ and “>” that cause Multi-style fields to display as a big mess. 

Tim

********************************************
Tim Nevels
Innovative Solutions
785-749-3444
[email protected]
********************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to