Question on @Command( [ViewRefreshFields] )

When the ‘If’ statement in the following code executes on the web, an ‘object variable not set’ error occurs.

Dim collection as NotesDocumentCollection

Set collection = doc.responses

If (collection.count > 0) Then   

Prior to running this code, I’ve verified in the Notes database, that ‘doc’ exists. I’ve also run a JavaScript ‘alert’ prior to this code to confirm that ‘doc’ exists. No response documents exist for ‘doc’, but that should not cause the ‘If’ statement to fail.

Here are additional details:

Prior to running this code, ‘doc’ is open in edit mode and a Save button is clicked. The Save button calls an agent that does a NotesDocument save. (The Save button does not use @Command([FileSave]) so that JavaScript alerts can be displayed.) The object variable error occurs only if the Save button also contains @Command( [ViewRefreshFields] ). This is needed to refresh the choices in an HTML select field and one of these choices runs the above code that causes the object variable error.

I’d appreciate any ideas on why @Command( [ViewRefreshFields] ) causes the ‘object variable not set’ error.

Thanks.

Subject: RE: Question on @Command( [ViewRefreshFields] )

Are you sure the message is “object variable not found” and not “object variable not set”? Because the message “object variable not found” doesn’t exist in the Domino source code.

The message means that the object variable has the value Nothing. Use the debugger. This is what it’s for. What does the Responses property return when there are no responses? The documentation says a collection with zero documents, but perhaps that’s not the case in some circumstances. It would appear that if the document has not been saved, perhaps it returns Nothing instead.

Because, guess what? If the documentation doesn’t match the actual operation of the function, the real world beats the documentation every time!

Subject: RE: Question on @Command( [ViewRefreshFields] )

Yes, you are correct - the message is ‘object variable not SET’. The document was saved however - I verified that it exists in the Notes database before running the code in which the error occurs. In addition, I added a JavaScript alert just prior to where the error occurs in the code in order to verify that the document exists. (The alert returns the document’s form name.) I therefore would expect that the responses property should return a zero since there are no response documents rather than generate an error.

I’d appreciate any other ideas on this. Thanks.

Subject: RE: Question on @Command( [ViewRefreshFields] )

Like “maybe you should check for Nothing”, maybe?

Subject: RE: Question on @Command( [ViewRefreshFields] )

Thanks Stan. Checking whether the collection is Nothing did the trick. I had tried:

If (collection = “”) then

However, that was not allowed because of a type mismatch error.

Subject: Confused

I think you have created a mess here. It would be best if you just try to explain what you want to do rather than how you are trying to do it.

Subject: RE: Confused

I realize it might be incorrect to assume that @Command( [ViewRefreshFields] ) is causing the error that I’ve seen. Hopefully the following description will make more sense:

A form contains an HTML select field and a Save button.

The HTML select field has choices that are displayed only after the document is saved.

The Save button contains @Command([ToolsRunMacro]) which runs an agent that saves the doc and also @Command( [ViewRefreshFields] ) to refresh the fields.

After the doc is saved and the fields are refreshed, a choice is selected in the HTML select field. This runs the following code:

Dim collection as NotesDocumentCollection

Set collection = doc.responses

If (collection.count > 0) Then

The problem is that ‘If’ statement fails with an ‘object variable not found’ error. I’ve verified that ‘doc’ exists (by using a JavaScript alert) and so it would seem that the error should not occur even if ‘doc’ has no responses.

I’d appreciate any ideas on why this error occurs. Thanks.

Subject: Keyword field

Why aren’t the choices for the keyword field available until after the document is saved? Are there other fields on the form that determine the choices?

Subject: RE: Keyword field

Yes, there are field values on the saved document that determine the choices in the HTML select field. The HTML select field is Pass Thru HTML and defined as follows:

If @Command( [ViewRefreshFields] ) is not included in the Save button, the choices do not become available following the document save. If @Command( [ViewRefreshFields] ) is included in the Save button, the choices become available, but selecting one runs the code in my original forum entry that results in an ‘object variable’ error.

An error does not occur if the document is saved and closed, then reopened and same choice is selected. That’s why I assumed that @Command( [ViewRefreshFields] ) in the Save button might somehow be related to the error.

Thanks again for any ideas.