Link to home
Start Free TrialLog in
Avatar of prpradip
prpradip

asked on

Differentiate between two forms with same name

Lotus notes allows me to create two form with exactly same name.
In programming how can I distinguish between these two forms and act on them differently. Is there any Id or something?
Avatar of mekhet30
mekhet30
Flag of South Africa image

Question - why in the world would you want to have two forms with the same name?   My logic tells me that you are just creating unnecessary complexity to you application.

Are the two forms Identical?  I'm asuming they are not, so you can differentiate between the two forms by the fields they have.

When you do you selection formula or selection scripts you can Identify the document using the form name and the field that is specific to the form.

The problem comes in when you are creating documents programatically, you cannot differenciate between the two forms cause you will always compose a document using the form name and Notes will use the first one it can find in the DB.  Unless there is another way that you can crate the document from a form that I do not know about.

Dunno if that helps

Cheers
Avatar of CRAK
It's useful if one is hidden for web and the other is hidden for notes clients. If a document is created in one, it can me displayed in the other.
Besides that option, I can only think of trouble!
Avatar of prpradip
prpradip

ASKER

Hey budy, I need to create document using different form according to Form it was created. And both FORMS has got same name.
Doesn't there is specific Form Id or something else?
Hey budy,

There is not an ID you can use to differenciate the forms.  

Again the question - why are you using the same form name to create the new document from other documents.  Just create the new document with a different form name?  

Lotus Notes will always use the first form in the list that are named the same.  Unless, like CRAK said, you are using one for web and one for notes.

Explain this in a little more detail and maybe we can find a better way to do what you are trying to achieve.  

E.g.  You have a DB with documents that have been created with form client
 - now you want to create new documents using the info of the existing documents using the same form name but with different fields? Essentially duplicating all the info in the database?  

That is how I understand your problem



Three scenarios of how editing in different forms is generally acomplished:

1) The document is opened through different views. Each view has a different form formula. Form names are different

2) The document contains a certain field (often status or doctype), controlling the loading of a (computed) subform. The different subforms contain the actual fields and there is only one form involved.

3) Before opening or while saving/closing a document, the form-field in a document is chnaged. Reopening will load a different form, with a different name.

If two forms exist, both having the same name (name+alias) and used in the same client, you simply can't control which of the two is actually used!
> Lotus Notes will always use the first form in the list that are named the same.  
Not exactly true, please read on.

A form has a name, but a form also has an alias. Even more aliases are allowed! For example, if I have a form "Customer Turnover" with an alias of "Turnover", I can use @Compose("Customer Turnover") or  @Compose("Turnover"), they are equivalent. Now, if you have a second form, with slightly different fields but used for almost the same purpose, you can give it a different name and the same alias. For example, the form "Our Turnover" with an alias of "Turnover".  @Compose("Our Turnover") will show the correct form, but  @Compose("Turnover") will still give you the Customer Turnover form, because it's shown earlier in the alphabetical list of views. So you'd have to find some other way to determine which form is to be used for which document (add a computed when composed field, or check the fields that are in the document).

> Besides that option, I can only think of trouble!
Hmm, don't really agree. Think of a multi-lingual database where there are 3 forms with the same alias but all in a different language. Okay, in this case, the form is selected based on the language preference of the user. Still very practical. And, yes, it's a maintenance issue. I can think of other examples form multiple forms with the same name, all very valid, for instance to avoid lots and lots of hide-whens.

Back to opening the document with a form. If you do nothing special, Notes will open the document with the form that's specified in the document's Form field. You can however open the document with a different form. The easiest way to do that is to create a view of those documents you need opened differently, and you set the Form Formula in the view (just below View Selection, in the Designer).

So, there can be valid reasons to use multiple forms with the same alias.
Thanx all of you for response.
My problem is my client has a NSF with two different Form with same name (both name and alias) (Why Notes allows us to do so?) and he wants to extract document from that NSF based on the Form it was created.
Don't really want to argue and I agree with you Sjef.

If you have two forms with the same form name but different aliases or different forms with the same alias if is possible cause you can differenciate between the two programatically when you are creating the document.

The question as stated by prpradip was can you differenciate between two forms using some sort of ID?  That is to say if the forms have the same form name and no alias or the same alias.  

That is how I understood the question.




No problem with that. I have to say it took me quite some time to figure out how this all works in Notes, but there still are some grey areas...
I am/(will be) looking for your answer sjef bosman......could u tell me about these grey areas.?
Prpradip, what are the differences in the forms? Are both forms duplicates so you could rename/remove one? Can one say that there's an old form and a new form, so that you could differentiate documents based on creation date?

I'd give at least one form a different name and alias. And I'd create a view to open a document with the "wrong" form.
Can you think of a formula that calculates correctly which of the two forms should be used? Use that form in the Form Formula in a view.
Exactly one Form is used in old and now there is new Form with same name + alias and that will create new documents. But if I want to view old documents how can it is possible and how can the document will be rendered if I export old documents. It is very problematic.
Rename the new form. You can also hide the new form. Or combine the two forms into one.

What are the differences between those forms??
These two forms have different set of fields...
How different? Completely different, very different, only a few fields?

If the view's form formula, you can use @IsAvailable to check whether a specific field is available in a document.
Only a few new fields were added to the new Form.....
So why don't you hide the old form? There's an option in the Form Properties to hide it.
yes.....bt what about exporting document that is created in old Form as the old Form rendering
Are there many differences in the old form, regarding rendering?

Suggestion:
- rename the old form to FormOld
- create a new view for the users
- give it the following Form Formula (you have to adapt the names etc.):
      @If(@IsAvailable(One_Of_The_New_Fields); "Form"; "FormOld")

Beware: once someone modified an old document with the new form, the new fields will have been added to the document.
You can set the form with two aliases.  This way you can use a view's form formula to open a document with different forms (like a limited form and an entry form) but save the document with the same form name.  Example:
1
Sample Form Entry| FormEntry | Form
2
Sample Form Limited | FormLimited | Form
Thank you sjef,
I know if I rename the old Form there is no problem. But this is against my question.

Anyway thank you for your valuable time.
Hey mross002,
Could you tell me the formula please.
Indeed you can give a form many aliases, as I said before, but still the document itself contains only one alias in the field Form (the last in the list of aliases, I forgot). So that's not really going to help, I think.

All you can do is test with @IsAvailable(field) to determine what form a document was created with.
The only real way to fool Notes to use a different form is to put a Form Formula in a view.

Finally, you can write an agent to help you. It selects the documents based on the @IsAvaliable(field) method, and modifies the Form field to "FormOld" or so. As of then, opening the document will always be correct. But... You have to adapt ALL views (and maybe more) that contain a selection formula like
      @SELECT Form="Form"
That formula needs to be changed, into
      @SELECT Form="Form" | Form="FormOld"
or in shorthand
      @SELECT Form="Form":"FormOld"

And, of course, you will modify a lot of documents, so if you have anything (agents) triggered on the Modified-date of a document, you'll see that a lot will happen.
Hi SJEF,
Can I get Form.NotesUrl in C programming?
What for?? A lot is possible in C using the C-API, but I think that's a different subject, and question.

Are you by any chance looking for NotesDocument.GetDocumentByURL?
Because When I used LotusScript it shows many things that I am unable to retreive in C programs
googling is giving nothing for many 'nnotes.dll' functions like URLFormWorkingURL, NSFNoteOpenForm and many more
http://www-10.lotus.com/ldd/46dom.nsf/55c38d716d632d9b8525689b005ba1c0/54feea2820bfc15a412568960034054b?OpenDocument
If you want to extend the Notes client, you need the C-API (maybe it is possible with the C++ API) and the LSX toolkit:
http://www.vcode.no/resource.nsf/GSWNAPI/391.htm

I seriously wonder what these questions have to do with the question you opened ("Differentiate between two forms with same name")...
Because I need to differentiate between two documents created by two different FORMs, HAVING SAME NAME  and ALIAS in my C program.
So that I can Find the exact Form that has created the DOCUMENT
AAAAAAAAAHHH.... You should have said so in the first place! But logically speaking, there is no difference. This question no longer really qualifies as a simple 50-point question, by the way...

The answer to your question is still:
- NO, if you look only at the form
- NO, if you look at the document,
- BUT you can maybe deduce it if you can see how a document is created.

You can see, as we said before, how a document is created by looking at the NotesItems that are present in a document. Looking at documents, a Notes database is just a pile of documents that can all be different. For example, your mail database contains 100 received mails, 100 sent mails, 20 appointments and 30 actions, the database contains 250 documents. If you want, you can trick a Notes client into using the wrong form for a document. A form's only use is to show the content of a document to the user. If the document contains more items (fields) than the form, too bad for these fields because they won't be shown. If a document does not contain all items, the Notes client provides a default value (from the default field formula).

So what you have to do is to check what items (fields) are in a document. If you find fields that weren't available in the original form, it is clearly built with the new form.

If I may ask: what kind of C application are you developing?
Details: I have two different Forms
1. RtfField | RTF
2. Others | RTF

In my C Program, when I extracted document I get both document contining Form = 'RTF'. This is resulting problem to me as I am not being able to get exact Form.
I am creating an application which will render the document as shown in NOTES UI because rendering of  ExportRTF(....)  method of 'nxrtf.dll' is very bad one. And I want to create my own rendering application which STRONGLY NEED which FORM the DOCUMENT GET CREATED!!!
STRONGLY NEED which FORM the DOCUMENT WAS CREATED!!!
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BTW I am still happy if anyone find exact method to do so...
Thnx sjef_bosman,
Very much.
CLOSING...