0
votes

A Name Text Box is bounded to a Names field in the related Notes form. How to make the values in the textbox into be converted automatically to CANONICALIZE when XPage is saved?

I have tried the following but they all failed. A) Saving the form using currentDocument.save() B) Use simple action "Save Document" C) add @Name([CANONICALIZE], @ThisValue) in the associated Notes form field under input validation, input translation and even as computed field.

5

5 Answers

1
votes

The OpenNTF Domino API has an openntfNABNamePicker dataProvider that you can use on a Name Picker control which provides this functionality. It has a returnNameFormat property to allow you to define whether the name should be stored in Abbreviated, Common or Canonical.

It may be possible to use a Converter as well, so that the name is converted to and from canonical format between browser and server.

1
votes

Try

document1.replaceItemValue("yourField", @Name("[CANONICALIZE]",document1.yourField));

in the querySaveDocument event of your xpage,

where document1:

<xp:this.data>
        <xp:dominoDocument var="document1" ... />
</xp:this.data>
0
votes

You can also use the following code in your save-script:

 var name:NotesName = session.createName(getComponent("inputText1").value)
document1.replaceItemValue("NameNA", name.getCanonical())
document1.save()

NameNA is your notes field of type "names" and "document1" is your datasource.

0
votes

The canonicalize needs something to work with. "John Doe" doesn't turn magically into "CN=John Doe/OU=ThePitt/O=GI"

Without a directory to find the name only something like "John Doe/ThePitt/GI" would canonicalize properly.

You could use @NameInfo to check if you can get the fullname back from a directory.

0
votes

The conversion is easy and no coding is involved using the OpenNTF Domino API.

I found myself looking for ways to resolve the issue above myself in my project, while Paul provided the answer, it took me a while to really understand how to go about it.

I'm adding an image below just to help anyone that may find themselves in a similar situation. It shows where to go to change the valueNameFormat property

enter image description here