Link to home
Start Free TrialLog in
Avatar of cashman
cashman

asked on

Document Created with agent doesn't have form?

Hi All,

this is a strange thing I have been experiencing:
I create a document

[...]
     Set db=session.currentdatabase
     Dim doc As New NotesDocument( db )

and assign a form to it:

     doc.form="someform"

then I set some values and save the document.
I have a view to show the documents of form "someform", but the newly created documents doesn't show up. I go to a view showing all document, open the new document, edit a field (for example add a blank) and save it. And magically then it shows up in the view showing "someform"...
It is not a problem of refreshing the view, I can hit F9 a hundret times and the doc doesn't show up...

Can anyone explain this to me?? I actually don't consider me a Notes-beginner, but this is a mistery to me...

Thanks a lot in advance,
cashman

Avatar of CRAK
CRAK
Flag of Netherlands image

Are you displaying a field created by the agent in the all someform-view while showing e.g. [documentno. in view] (not a specific field) in the all documents view?

A field (NotesItem) has a property "IsSummary". It determines wether or not a field can be displayed in a view.

What could be happening is that the document is shown as an empty line since the created fields don't show yet.
When editing it (front-end) those properties are recalculated and set to True.
Avatar of hshevitz
hshevitz

Hmmm, tried to duplicate this with a simple test script and it worked OK for me. What else is in your code to create the document?

Test Script:

     Dim session As NotesSession
     Dim db As NotesDatabase
     
     Set session = New NotesSession
     Set db = session.CurrentDatabase
     
     Dim doc As New NotesDocument(db)
     
     doc.Form = "someform"
     doc.Field1 = "Field 1"
     doc.Field2 = "Field 2"
     doc.Field3 = "Field 3"
     
     Call doc.Save(True, False)

View has selection formula of SELECT Form = "someform"

This works ok
Ok so are you basicly saying the document DOES appear in your ALL DOCUMENTS view but it DOES NOT appear in a different customized view until the document is resaved?  If this is the case then please post your view selection formula for the different view.

-Snocross
   Dim session As NotesSession
    Dim db As NotesDatabase
    Dim item as notesitem    

    Set session = New NotesSession
    Set db = session.CurrentDatabase
   
    Dim doc As New NotesDocument(db)
    Set item = New NotesItem(doc,"Form" , "SomeForm")
    item.IsSummary = True
    doc.Field1 = "Field 1"
    doc.Field2 = "Field 2"
    doc.Field3 = "Field 3"
   
    Call doc.Save(True, False)

Try this instead of doc.Form = "someform"

Rgds,
Arun.
PS: Please increase the points since i have not earned some in quite a while now and no one is allowing me to steal their points too... :-)


It works with

  doc.form = "someform"

and doesn't work with (same as with the cashman description)

  Set item = New NotesItem(doc,"Form" , "SomeForm")

I have duplicated the problem using the "Set item..." statement.
Avatar of cashman

ASKER

Hi All

Thanks a lot for your comments.

What I found out now:
First:
The Script works well if what is set with

doc.form="xy"

is the same as the

SELECT form = "xy"

in the viewselection

When I use aliases it does not work :(

This is also, why hshevitz's Set Item doesn't work while the doc.form works...

Second:
Running a lotusscript-agent with target "all documents in view" doesn't work if there a no doc in the view :)) Specifying "None" works a lot better...


Well now...the interesting question for me is: Why does it not work when I enter an alias? Did I misunderstand aliases completely?


regards,
cashman

Avatar of cashman

ASKER

maybe I should add a better example:

if the viewselection is

SELECT form = "someform"

the doc.form= must be doc.form="someform" and cannot be "otherform" even if this is an alias.


regards,
cashman



Well...now...

Alais is the only value that is stored in the document.

And when a document opens with the form at its base then it displays the name and not the alias.  This is determined by the form with which the document is opened.

The view does not have anything to do with the form as such. It displays only the documents. And the documents contain only alais name.

Hope this clears things a lot better right ?

-Arun.
Avatar of cashman

ASKER

maybe I should add a better example:

if the viewselection is

SELECT form = "someform"

the doc.form= must be doc.form="someform" and cannot be "otherform" even if this is an alias.


regards,
cashman



In code, always set the form name to the "real" form name...not the alias. If the form name is set as

Alias Form | frmRealForm

You will always use frmRealForm in your code.

doc.Form = "frmRealForm"

Hope this gives you a clear picture.

HS
uh Oh...

Always set the alias name.  The views need not be altered.

-Arun.
ASKER CERTIFIED SOLUTION
Avatar of Arunkumar
Arunkumar

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
Avatar of cashman

ASKER

Hi All,

*completely confused*
Did I get that correctly that I can't use

"someform"

and

"someformalias"

equally in my code? I always thought that I can use the as if they where the same...

One more question: If the "real" formname is not stored in the document, how can it be that with my original problem I could edit the newly created document and then it was displayed in the view?


thanks and regards,
cashman
Oops, got my terms reversed:

Leftmost name is the original name
Rightmost name is the alias name

Let me change this around...

In code, always set the form name to the "alias" form name...not the original name. If the form name is set as

Original Form | frmAliasForm

You will always use frmAliasForm in your code.

doc.Form = "frmAliasForm"

Your View selection formula should be

SELECT Form = "frmAliasForm"

Now, I'm sure I have confused everyone! Sorry about that! :-(

HS
This is a known problem in R5.

The workaround as suggested by Lotus is to repeat the alias name once again in the form name property.

SOURCE: http://www-1.ibm.com/support/docview.wss?rs=475&context=SSKTWP&q=1102039&uid=swg21102039&loc=en_US&cs=utf-8&lang=en

~Hemanth
Avatar of cashman

ASKER

@Hemanth : Not sure which problem you mean by "this"...(btw: I am using Notes 6)

Can you please verify the new documents propertybox in the all documents view? Check the FORM-fields value and any field flags mentioned.
Maybe it was not fixed in R6 too.

Repeat the alias and see if helps.

In your case it would be

Form Name|someform|someform
Avatar of cashman

ASKER

Hi All,

as things got rather messy I'd like to sumarize here:
Problem:
I create a doc from an gent and set the doc.form property. The doc doesn't show in my view. (to be very short)

Solution:
Work only with aliases in the code (I did set doc.form to the name, not alias).

Other stuff:
I am confused about how aliases work. I always thought I can use one or the other, no difference. In fact only the alias of the form is stored in the documents created from them. When setting the from-field from code it is my duty to make sure that the alias is there and not the name of the form.
If you use the formname you can see the document only in a view showing all docs, editing such a document will change (!) the value of the "form" field to the alias of the form the doc was created on. This is why everything works if a "problematic document" is resaved.
I think that by now I understood the alias-thing (though I still think it is not really logical)

Next problem: How do I decide who gets the points? (Serious question as this is my first Post here and noone gave me the_ answer


regards,
cashman



PS: @CRAK: To have your question answered: the fields are OK, I "just" messed up things with wrong use of aliases
to who ever you want to award points just accept comment as answer link right to the name.  And grade it accordingly.

If you wish not to give anyone points post a link to this question to the community support and they will delete it for you !

-Arun.