No Value in document's "Form" field

Hey, I’m having a odd issue. In the Postopen of a form I am binding an event for the Querysave. The code looks something like this:

Select Case Source.Document.getItemValue(“Form”)(0)

Case "Workflow":

	On Event Querysave From Source Call createDefaultState

		

Case "State":

	On Event Querysave From Source Call createDefaultApprover

End Select

Set Me.attachToForm = Me

As you can see, this is the code from a utility function called in every form. It is supposed to look at the type of form and decide which function to bind to the Querysave.

The problem is that when the document is new (created for the first time) it has no value in the field “Form”. Therefore, document.getItemValue(“Form”)(0) returns nothing.

Weird. And it only happens on the form “State”. The other form with binding works fine. The binding works just fine when opening an existing document.

Any ideas on why the document has no “Form” field when first created?

Thanks, Nick

P.S. what is the correct choice to put in “Technical Field” on a post like this?

Subject: Working correctly if you do not have a hidden ‘form’ field …

I’m assuming that you do not have a computed hidden field called ‘form’ with the forms alias in it and that you are not storing the form with the document.

Therefore, the notes document in memory does not have a notes field (item) with the form alias as a value in it during the QuerySave event. The form field is populated during save, not prior to the save.

You can either;

1 - set the Form field value in the form design

2 - move the code to the PostSave event

just depends on what you are trying to do.

Two help references.

Check ‘Forms and Documents’ and ‘Event Descriptions’ for information about how documents and form designs interact and when events are fired.