Working with multi-line text fields
The formattedTextSupport operation enables or disables formatted text for multi-line text fields. Use true to enable formatted text or false to disable it.
When set to true, the HTML is retrieved from the field. For example:
<p><em><strong>This</strong> is wysiwyg text.</em></p> is returned instead of: This is wysiwyg text.
See Multi-line text field supported fonts and HTML tags for more information.
The attachlist fields contain a list of images in a multi-line text field. The list is an array of CFileAttachment[].
Editing text values
Multi-line text fields can include plain or rich text. All formatting is removed if a field is edited as plain text. Inline images are preserved, but they are appended to the end of the field. Use the formattedTextSupport operation to control how a field is edited.
For example, an issue's Workaround field contains the following formatted text:
Some text here
The text is stored in Helix ALM as:
<p>Some <strong>text</strong> here</p>
The following example shows how to edit this value as plain and rich text.
ttsoapcgi svr;
...
svr.formattedTextSupport(cookie, true);
CDefect dft = svr.getDefectByRecordID(cookie, id, false); // returns "<p>Some <strong>text</strong> here</p>" in the Workaround field
svr.formattedTextSupport(cookie, false);
dft = svr.getDefectByRecordID(cookie, id, false); // returns "Some text here" in the Workaround field
Multi-line text fields can contain inline images. The following example shows how to add an image to a field.
// Make sure rich text is enabled
bool richTextEnabled = ttsdk.formattedTextSupport(cookie, true);
string filename = "Example1.png";
CFileAttachment file = new CFileAttachment();
file.mstrFileName = filename;
System.IO.FileStream fs = new System.IO.FileStream(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader reader = new System.IO.BinaryReader(fs);
file.mpFileData = reader.ReadBytes((int)fs.Length);
reader.Close();
fs.Close();
CDefect def = ttsdk.editDefect(cookie, 0, "Defect summary", false);
def.workaround =
" <p align=\"center\"><span style=\" font-size:24pt;\">Helix ALMSOAP</span></p><hr />\r\n"
+ "<p><img src=\"Example1.png\" />";
def.workaroundInlineAttachList = new CFileAttachment[1];
def.workaroundInlineAttachList[0] = file;
ttsdk.saveDefect(cookie, def);
You can also edit images in multi-line text fields. The attachment record must exist and be referenced by the multi-line text field value.
For example, an issue's Workaround field contains the following text and image:
Some text and an image 
The text and image is stored in Helix ALM as:
<p>Some text and an image <img src="00000001.dat" /></p>
In this example, the image is already saved in Helix ALM and referenced using the archive name of the saved image attachment data, not the filename. The archive name is a unique identifier assigned when the image attachment is uploaded. If attaching a new image, you would use the filename in the img tag and Helix ALM matches it to the attachment record with the same filename.
The following example shows how to upload an image to an issue's Workaround field.
ttsoapcgi svr;
...
svr.formattedTextSupport(cookie, true);
CDefect dft = new CDefect();
// The workaround value references the image by the full path name
dft.workaround = "<p>Some text and an image <img src=""C:\SomeFolder\fileimage.png"" /></p>";
// In the workaround attachment list, the filename must match the referenced name
dft.workaroundInlineAttachList = new CFileAttachment[1];
dft.workaroundInlineAttachList[0] = new CFileAttachment();
dft.workaroundInlineAttachList[0].m_strFileName = "C:\SomeFolder\fileimage.png"";
dft.workaroundInlineAttachList[0].m_pFileData = <the file's data>;
// The issue is added with the inline attachment in the Workaround field
svr.addDefect(cookie, dft);
When retrieving the issue, the Workaround field value is updated with the archive name, as shown in the following example.
ttsoapcgi svr;
...
svr.formattedTextSupport(cookie, true);
CDefect dft = svr.getDefectByRecordID(cookie, id, false);
// The workaround value references the image archive name
Console.WriteLine(dft.workaround); // Prints: "<p>Some text and an image <img src=""00000001.dat" /></p>"
// In the workaround attachment list, the archive name matches the referenced name
Console.WriteLine(dft.workaroundInlineAttachList[0].m_strArchiveName); // Prints: "00000001.dat"
// The attachment record retains the original file name
Console.WriteLine(dft.workaroundInlineAttachList[0].m_strFileName); // Prints: "fileimage.png"
After an image attachment is saved as an archive, the file data is not returned unless explicitly requested. To retrieve an inline image, the get or edit request must have the include attachment data flag set and formatted text support must be enabled. For example:
ttsoapcgi svr;
...
svr.formattedTextSupport(cookie, true);
// Returns archive data
svr.getDefectByRecordID(cookie, id, true);
// Will not return archive data
svr.getDefectByRecordID(cookie, id, false);
svr.formattedTextSupport(cookie, false);
// Will not return archive data
svr.getDefectByRecordID(cookie, id, true);
// Will not return archive data
svr.getDefectByRecordID(cookie, id, false);