Previous Topic

Book Contents

Book Index

Next Topic

Rich Text Data Specifics

Rich text data are stored in pair attributes. An example of this <attribute>/<attributeRich> pair is ticket description represented by attributes:

  • Ticketdesc.description - attribute containing plain text values
  • descriptionRich - attribute containing rich text values

The combination of a plain text and rich text attribute brings about the following specifics described below.

Getting/Setting Rich Text Data by Workflow Script

Getting values:

Methods getValue(), getRtfHTMLValue() and getRtfPlainValue() are available.

  • getValue()

    The method can be used on both plaintext and richtext attribute (e.g. 'Ticketdesc.description' and 'descriptionRich') and it returns plaintext value when used on the plaintext attribute and richtext value when used on the richtext attribute. For example:
    bo.getBOField("description").getValue() -> plaintext value
    bo.getBOField("descriptionRich").getValue() -> richtext value

  • getRtfHTMLValue()

    The method can be used on any of the 2 attributes of a plaintext/richtext pair and it always returns richtext value. For example:
    bo.getBOField("description").getRtfHTMLValue() -> richtext value
    bo.getBOField("descriptionRich").getRtfHTMLValue() -> richtext value

    where richtext value is the value contained in the richtext attribute of the attribute pair.

  • getRtfPlainValue()

    The method can be used on any of the 2 attributes of a plaintext/richtext pair and it always returns plaintext value. For example:
    bo.getBOField("description").getRtfHTMLValue() -> plaintext value
    bo.getBOField("descriptionRich").getRtfHTMLValue() -> plaintext value

    where plaintext value is the value contained in the plaintext attribute of the attribute pair.

Setting values:

Methods setValue(), setRtfHTMLValue() and setRtfPlainValue() are available.

  • setValue()

    The method can be used to set a plaintext value to a plaintext attribute or richtext value to a richtext attribute. It behaves in the following way:

    • When the method is called for a plaintext attribute, it expects a plaintext value.
      1) It sets the value to the plaintext attribute of the plaintext/richtext pair, and
      2) It coverts the value to richtext and sets this converted richtext value to the richtext attribute of the plaintext/richtext pair
    • When the method is called for a richtext attribute, it expects a richtext value.
      1) It sets the value to the richtext attribute of the plaintext/richtext pair, and
      2) It coverts the value to plaintext and sets this converted plaintext value to the plaintext attribute of the plaintext/richtext pair

    This means that if richtext content is set to a plaintext attribute, the richtext formating is kept and displayed in the text.

  • setRtfHTMLValue()

    The method can be used to set a richtext value to the plaintext/richtext pair. When the method is called for any of the 2 attributes of a plaintext/richtext pair, it
    1) Automatically sets the value to the richtext attribute
    2) Converts the value to plaintext and sets it to the plaintext attribute

  • setRtfPlainValue()

    The method can be used to set a plaintext value to the plaintext/richtext pair. When the method is called for any of the 2 attributes of a plaintext/richtext pair, it
    1) Automatically sets the value to the plaintext attribute
    2) Converts the value to richtext and sets it to the richtext attribute

For example, when setting a plaintext value to a plaintext/richtext pair, one of the following equivalent ways can be used:

  • bo.getBOField("description").setValue("plaintext value")
  • bo.getBOField("description").setRtfPlainValue("plaintext value")
  • bo.getBOField("descriptionRich").setRtfPlainValue("plaintext value")

A richtext value will be automatically created from the given plaintext value (special characters must be escaped, line ends are replaced with <BR> etc.) and set to the richtext attribute.

Analogically, when setting a richtext value to a plaintext/richtext pair, one of the following equivalent ways can be used:

  • bo.getBOField("descriptionRich").setValue("<b>richtext value</b><br>")
  • bo.getBOField("description").setRtfHTMLValue("<b>richtext value</b><br>")
  • bo.getBOField("descriptionRich").setRtfHTMLValue("<b>richtext value</b><br>")

A plaintext value will be automatically created from the given richtext value (all formatting will be removed) and set to the plaintext attribute.

When parsing richtext to plaintext, the image tag fragment is written as space.

Check Rich Text

The Rich text control expects data in HTML formatting. One of the consequences is that the end of line information is lost when a plain text attribute is changed into rich text. For example, plain text attribute containing e.g.:

First line.
Second line.
is rendered in HTML as:

First line. Second line.

because there is no HTML tag at the end of the line (i.e. First line.<br> Second line).

The problem can be solved by a 'Check Rich Text' tool transforming the plain text data into HTML. The tool can be used for a pair attribute in cases when the content of the plain attribute contains end of line characters and the content of the rich attribute is equal to the content of the plain attribute.

The 'Check Rich Text' tool is available:

  • As a right-click popup command on the name or translated name of the pair attribute in the 'Used Attributes' list of Object Type Customizer.

    Help Image

  • As a check option in Metamodel Check.
  • As part of data migration procedure.

See Also

Rich Text Control Customization