doanvv
doanvv

Reputation: 21

C# How to get field's properties (Field type, default value, formula, ..) in Lotus Notes using Interop.Domino.dll

I'm working with Lotus Notes using Interop.Domino.dll library, but I don't know how to get field's properties (including field type, default value, ...).

Upvotes: 2

Views: 698

Answers (2)

Andreas
Andreas

Reputation: 992

As Richard already mentioned. Use the DXLExporter

var exporter = lnSession.CreateDXLExporter();
exporter.OutputDOCTYPE = false; //shortens the XML a bit

and then export the NotesDocument to an XML-Representation.

var xml = new XmlDocument();
String s = exporter.Export(notesDocument);

//remove the namespace for easier XPATH
s = s.Replace(" xmlns='http://www.lotus.com/dxl'", ""); 
xml.LoadXml(s);

In the XML, there are the notes items f.e.:

<item name='$CSVersion'><text>2</text></item>
<item name='StartDate'><datetime>20160323</datetime></item>

as you can see, there is at least a basic type information in there to work with.

If you have the names and types sorted out, you may get the item with

notesDocument.GetFirstItem(itemName); //return NotesItem

or the value directly with

notesDocument.GetItemValue(itemName);

which will return an Object, which you can cast afterwards to the desired type.

Upvotes: 0

Richard Schwartz
Richard Schwartz

Reputation: 14628

There is a NotesForm class, and you can get the names of fields from that, but there is no class available to represent a field and its attributes. You'll have to use the NotesDXLExporter class to get an XML representation of the form and parse the XML to get the field properties.

And you're probably better off going with DXL for any information you need about design elements, anyhow, because there are known problems with the interop classes that represent collections of deisgn elements when running on 64 bit Windows - which is not officially supported by IBM.

Upvotes: 2

Related Questions