How to prevent WQO be triggered by event other than opening the form?

Indeed this has been posted but I change the subject description here.

I have searched the forum and found the same problem had been experienced before but there is no solution on that.

I need to execute some codes on WQO agent when opening a document on read mode from a view, however, the WQO codes run again when I close the document using a button with simply @PostedCommand([FileCloseWindow]).

However if the document is open in edit mode, on closing the document using a button with @PostedCommand([FileSave]);

@PostedCommand([FileCloseWindow]), the WQO agent will not be run again (I got a $$Return Field on my form to direct back to target view)

Another question is that when I click the button with @Command([EditDocument]) on the web, WQO codes will be executed again, how can I check editmode on the web so that to prevent the execution? I try to look up EditMode property but is on UIDocument only.

Thanks in advance.

Subject: How to prevent WQO be triggered by event other than opening the form?

I have a case where I only want to run when I am in edit mode:

@If(@IsDocBeingEdited;@Command([ToolsRunMacro]; “webLock”);“”)

If you change the order around, then you sould be able to run it only in read mode:

@If(@IsDocBeingEdited;“”;@Command([ToolsRunMacro]; “webLock”))

Subject: Can I set global variable using formula

Thanks for all your responses, I finally solved the editmode checking condition using formula.

Yet I still can’t figure out why WQO will be triggered when my Quit button with just @Command(FileCloseWindow) is clicked.

(In fact I have tried that if I press the IE button to return to the view, WQO will not be run. But if I click my Quit button, WQO will be triggered, strange?)

I therefore think of some dirty codes to avoid running WQO by setting a global variable when I press the Quit button (I don’t wanna create a field since the doc will then need to be updated) so that I can check it inside WQO agent, but since global variable cannot be used in formula, I have no idea how to set a global variable before @Command(FileCloseWindow).

Any idea?

Subject: How to prevent WQO be triggered by event other than opening the form?

This is some code that I use in my close buttons on the web instead of @Command([FileCloseWindow]). As long as you are not passing in any parameters then EditDocument, OpenDocument or OpenForm will always be the last element of the array.

var url = window.location.href.split(“?”);

//check whether user has put document into edit mode from read mode

if (url[url.length - 1].toUpperCase() == “EDITDOCUMENT”) {

window.history.go(-2);

} else {

window.history.go(-1);

}

Subject: How to prevent WQO be triggered by event other than opening the form?

This is some code that I use in my close buttons on the web instead of @Command([FileCloseWindow]). As long as you are not passing in any parameters then EditDocument, OpenDocument or OpenForm will always be the last element of the array.

var url = window.location.href.split(“?”);

//check whether user has put document into edit mode from read mode

if (url[url.length - 1].toUpperCase() == “EDITDOCUMENT”) {

window.history.go(-2);

} else {

window.history.go(-1);

}

Subject: How to prevent WQO be triggered by event other than opening the form?

I have a case where I only want to run when I am in edit mode:

@If(@IsDocBeingEdited;@Command([ToolsRunMacro]; “webLock”);“”)

If you change the order around, then you sould be able to run it only in read mode:

@If(@IsDocBeingEdited;“”;@Command([ToolsRunMacro]; “webLock”))