How to get fieldname

Hi experts,

I’m working on developing a Notes plug-in. After I opened a document in Notes client, which contains a lot of Fields, how can I get the name of a field? Now I can get the document object, as known, using doc.getItems(), I can get all of itemname/value pairs, but my question is, how can I know a certain itemname by its value.

Any ideas?

Subject: Do you know the field value ?

Are you asking “If I know a field value, but not the name of the field, how do I get that name ?”

If so, you would need to loop through all of the document items, and see which ones match the value that you have.

If you were asking for something else, please clarify your question. Perhaps with an example ?

Subject: Hi

Hello Graham,

Thanks for your response. I’m looking for a method to get the name of a certain field, no matter I know its value or not. You are right, if I know its value, so I can loop through all of the document items to look up which one matches. But it doesn’t work, if there are two or more items that have the same value. Moreover, sometime the value can be null or “”.

I just had an idea. It looks like awkward, but it works. I add “onfocus” event to each visible field like this:

Sub Onfocus(Source As Field)

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument

Call	uidoc.FieldSetText("TmpCurrentFieldName",uidoc.CurrentField)

'Print uidoc.FieldGetText("TmpCurrentFieldName")

End Sub

TmpCurrentFieldName is the name of a field that will be hidden in a form. Everytime, if I want to know the name of a field, I just need to click on the targt field and then get the value of TmpCurrentFieldName field using notes api.

Do you have any suggest for me? Looking forward to your response.

Subject: Sorry, I still don’t understand.

When you say you want to get the name of “a field” what is the field you want to get the name of ?

I’m really not clear on what it is you are trying to do, or why.

It sounds like you want to know the field-name on the form for a field of an open document - but in that case, just open up the form in designer and take a look at it there.

I don’t know if this will help, but there’s now a @ThisName formula that will return the name of the current field when used in field-level methods.

Subject: hello

I’m developing a sidebar plug-in, I want to know, how can I make user easily to get the name of the field, whose value will be set as a condition for searching documents that match. For example: a “Contact” form has a lot of fields, “Name”,“Age”,“Country”,“Email” and so on, there are 100 documents based on this form. Now user maybe wants to send all the people from US an Email, so he needs to know the name of “Country” field and enter “Country” as Fieldname, “US” as Value, “Email” as Output-Fieldname in the sidebar plug-in, then click Search to get a list of Email addresses.

Of course, I can open Designer to get it, but for normal user, it seems a little complicated.

With @ThisName it works better, thanks.

I’m new in Notes formula and Lotusscript, I still need more to learn.

Subject: Understood - you may need help from someone who knows how Composite Applications work.

Now I see what you need. You want one application (sidebar) to be able to identify fields by name that the cursor is on in another window.

Unfortunately I’ve not looked into composite applications yet, so I have no idea if that’s possible or not, or how you would do it. In general though, you would have problems handling fields that don’t store values in the document under the same name.

For example, an application that has fields on the form that the user fills out, but manipulates the values and stores them in the document under different item names.

Also, Computed for Display fields would not work, as they are not saved at all.

Subject: Another question about right-click menu

Thanks a lot.

Now I have another question, how could be the right-click menu on a Field or an opened document extended? Does it seem like impassable?