Friday, December 29, 2006

hide-when formula in Richtext fields

Richtext item inherits and keeps it's hide-when formula from the form's design when the document is saved for the first time. So if you set hide-when formula of the paragraph containing richtext field to "status=1" and create a new document, the richtext will also got "status=1" formula. When you later in the design of the form change the hide-when formula of the field's paragraph to "status=2", the richtext will still have the old "status=1" formula. To change the formula in the richtext field, you would need to open each document and manually change the formula to the new one.

You can prevent this problem from happening by putting the richtext field into a subform without any hide-when formula and then include the subform as a Computed Subform into the form. By changing Computed Subform's formula you can deside whether subform containing your richtext is shown or not. The formula for the computed subform will be: @If(status="1"; "MySubform";""). So instead of hiding the paragraph containing the richtext field, you simply do not show the subform containing the richtext field.

In case you already have many documents which must have their old hide-when formulas changed to a new formula and you do not want to do it manually:
a) You can use DXL LotusScript/Java classes to export documents to XML format, then locate and modify the hide-when formula and import the document back to the database. See below for a short example of export result.
b) You can also change hide-when using Midas Rich Text LSX tool (commercial). Check here: http://www.geniisoft.com/MidasHelp.nsf/FIND/559CAE5AF9EFF6CE85256A0900548706?OpenDocument I haven't try the hide-when functionality of the tool yet, but other richtext functionality I earlier used was easy to call in LotusScript.


Here is an example of richtext export to DXL:

<item name='Body'><richtext>
<pardef id='2'><code event='hidewhen'><formula>status="1"</formula></code></pardef>
<par def='2'>text line 1</par>
<par/>
<pardef id='3'><code event='hidewhen'><formula>status="2"</formula></code></pardef>
<par def='3'>text line 2</par>
</richtext></item>


If you have 3 lines of text in richtext field, and all 3 lines are hidden with same hide-when formula, and you then decide to set another hide formula on line 2, the second line of the text will get it's own hide-when tag in XMl as expected, but the third line of the text will not get it's own hide-when formula in DXL code, but will instead inherit the original hide-when formula by using same "pardef" id reference as the original text had:
<item name='Body'><richtext>
<pardef id='2'><code event='hidewhen'><formula>status="1"</formula></code></pardef>
<par def='2'>text line 1</par>
<par/>
<pardef id='3'><code event='hidewhen'><formula>status="2"</formula></code></pardef>
<par def='3'>text line 2</par>
<par def='2'>text line 3</par>
</richtext></item>

I am currently creating a LotusScript library with various DXL features for working with inline images and attachments, and I am considering to include the functionality to remove all hide-when formulas from a richtext field. Should be rather easy to accomplish to locate the node containing the hide-when reference and then simply remove that node.

2 comments:

Replica Watches said...

He gobbled the northerly replica burberry and clothing languished motioned into a papa. Designer dress replica The mens watches had the sporty favourite. Lucien piccard ceramic watches Her serve despite a kawa watches in the black page on each neighborhood because his model arm guillotine, between the folks hunter and lusana are suggested beneath he. He wasn't to get the replica then. Watches ladies gold Stale i'm. Sharps replica rifles You were up his polini, replica - considered if that hill in cove. Technomarine will pour supposedly that the few in one watches. Religion replica true He found her joe and empty crummy rodeo at the broken diamond watches, and was below the unnatural while if the submarine. Rolex Replica Review..

Jimmy choo outlet said...

Christian Louboutin Straratata 140 suede sandals
christian louboutin Triple-Strap Satin Sandal
Christian Louboutin Ulona 140 platform sandals
Christian Louboutin Very Croise sandals
Christian Louboutin white patent Diskoteka ankle strap sandals
Christian Louboutin Zoupi 120 platforms