This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



May 9, 2012, 1:03 AM
27 Posts

Detecting NotesItem Object Type with SSJ

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: NotesItems RichText Javascript
  • Replies: 3
 Hello!
 
Using server side javascript, can anyone tell me how to determine whether a field is a RichTextItem or a TextItem?  I'm trying to duplicate this LotusScript which is working:
 
Set rt1 = doc.Getfirstitem("DataField")
If rt1.Type = RICHTEXT Then
Print rt1 
Else
Print rt1.text
End If
 
 My best attempt looks like:
 
var:NotesItem rt1 = doc.getFirstItem('DataField');
if(rt1.getType()==???) { // Not sure what this should be!
print rt1;
} else {
print rt1.getText();
}
 
...but unfortunately I can't find any good API documentation on server side javascript objects.  "getType()" seems to be returning me "1.0" which I don't know what that means.
 
Any help would be sincerely appreciated!!!
Thanks in advance,
 
Alex
 
PS - Does anyone know where I can find API docs detailing properties and methods of javascript objects?  I find the IBM site ( http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp ) is just not that helpful (or it's too hard to find things - eg. if you search on "rich" you will not get a listing for NotesRichTextItem.
May 9, 2012, 7:11 AM
126 Posts
Re: Detecting NotesItem Object Type with SSJ
You don't need a special API for this, this can be done with just normal javascript.
 
Example: 
 
var doc = currentDocument; 
var item = doc.getValue("Body"); 
print("Body: " + typeof item); 
 
 
console: 
 
HTTP JVM:    Body : com.ibm.xsp.model.domino.wrapped.DominoRichTextItem 
 
typeof is a standard method of javascript as given the loosely bound nature of its variables it is required from time to time, epically in validation.
 
Hope this helps. 
May 9, 2012, 8:23 AM
2 Posts
Re: Detecting NotesItem Object Type with SSJ
You can also update yourcode this way:
 
if( rt1.getType() == lotus.domino.Item.RICHTEXT )
 
This is the Java syntax. It is also valid in Javascript.
 
Regards,
 
Lionel
May 9, 2012, 3:55 PM
27 Posts
Re: Detecting NotesItem Object Type with SSJ
 Excellent!  Thank you both for your answers!

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal