Monday, August 25, 2008

Workaround: ViewRefreshFields does not trigger WQO

A form I'm working on gets a combobox (or select list, if you prefer) generated by a WebQueryOpen agent. The content of the combobox is generated on the basis of another field.

I use one combobox to select a db, then the second shows documents in the selected db.

When I select a db, I want to generate the select list with documents in the selected db. I first considered running ViewRefreshFields, but WQO-agents don't get triggered by this.

It seems that running agents with the ToolsRunMacro @Command keeps the form as it was before the running of the agent.

The workaround, then, is quite simple. Add a hidden button (style="display:none") on the form. OnClick on the button, run the agent generating HTML (and ViewRefreshFields, if you need to refresh the form). Onchange in the db-combobox, click the button.

document.getElementById('your-id-in-the-button').click()


If you've used a similar approach, and found weaknesses with it, please let me know in a comment.

3 comments:

Tim Tripcony said...

If memory serves, .click() only works in Internet Explorer. I might be wrong, though.

Tommy Valand said...

It works in IE6/7, FF2 and Opera 9.5 at least.

I can't say that it works in all browsers, but at least in all the browsers I use.. :)

sam said...

In my case, ToolsRunMacro call to the same WQO agent worked.

Version: R6.5.4

Sorry for late comment, I tried this immediately when I read your post.

Regards,
Sam.