dev.kanngard.net make sure you visit my new blog at: johankanngard.net

Short tip: Combining a text and rich text field into a rich text field

by Johan Känngård / [@Formula] / 2002-10-06 / #39


Scenario

You have one text field, called Text, and a rich text field, called Body, that you want to combine into one rich text field called Body.

Step 1

Create a temporary Computed text field in the form, named Body2, with the Value formula:

@Abstract([TEXTONLY]; 50000; ""; "Body");

Create a temporary Computed rich text field in the form, named Body3 with the Value formula:

Text + @If(
	Body2 != "Body"; @NewLine + Body2;
	""
);

Step 2

Run an @Command([ToolsRefreshSelectedDocs])-agent on the documents you want to update. This populates the Body3 field, which contains the concatenated values of Body and Text.

Step 3

Replace the Body field with contents of the temporary Body3 field with an agent:

FIELD Body:=Body3;

Step 4

Delete the temporary fields Body2 and Body3, and the old Text field with an agent:

FIELD Body2:=@DeleteField;
FIELD Body3:=@DeleteField;
FIELD Text:=@DeleteField;

Step 5

Remove the fields Body2, Body3 and Text from the form. Remember that you can not show a Rich Text field in a view.