1
votes

I have a xpage that contains a button that pulls values from multiple fields, formats the text and sets that value into a rich text field on the backend document and saves it.

When I open the document on the Notes side the field is formatted correctly even though the field type indicates it is a Text. When I open the document in the browser all formatting is lost and the text is one continuous string. If I run an agent that contains @Command([ToolsRefreshSelectedDocs]) the field converts to Richtext and the xpage displays the contents correctly as well as the Notes Document.

Is there a way that I can set the value and retain the formatting or refresh the document to format the contents when saving the document from the web?

Sample code from button

var val;
var surveystandard = getComponent("FStandard").value;
var totalspaces = getComponent("TotalSpaces").value;
....

//Parking
if (!!totalspaces){
    val = val + "\n";
    val = val + "PARKING" + "\n";
    val = val + "\u25cf" + "\t" + "There are " + totalspaces + " parking spaces, with " + accessiblespaces + " marked accessible spaces, " + vanspaces + " of these are marked van accessible, " + carspacesrequired + " car accessible space(s) and " + vanspacesrequired + " van accessible space are required.";
    val = val + "\n";
if (parking != "" && totalspaces == ""){
    val = val + "PARKING" + "\n";
    formattedValue = formatCustomList(parking, customparking);
    val = val + formattedValue;  ........

//Set value **********

document1.setValue("Notes", val);

I've tried a couple of things using a NotesRichTextItem but they didn't work..

var notesRTF:NotesRichTextItem = document1.getDocument().createRichTextItem("Notes");
notesRTF.appendText(val);

This code generates an error....

Script interpreter error, line=749, col=58: [TypeError] Exception occurred calling method NotesDocument.createRichTextItem(string) null

Once the script block finishes there is a Save Document step that executes a simple action.

Any ideas or suggestions would be great.

Thanks in advance!

1

1 Answers

0
votes
Exception occurred calling method NotesDocument.createRichTextItem(string) null

This error message occured when the document already contained the rich text item with the same name. Check first if the item exists already or not.


Update: It seems the same javascript variable can not be used to store different rtitems:

var rtMegjegyzesek:NotesRichTextItem=ugyDoc.createRichTextItem('megjegyzesek');                     
var rtMegjegyzesek:NotesRichTextItem=ugyDoc.createRichTextItem('megjegyzesekExport');

This lines above raised the same error...