@Commands execution order on Web

I have a Web form with some fields on it and an $$Return field. On the submit button I am validating the fields with formula language and upon success, I would like to run an agent and if that agent runs successfully to save and close the form by opening a new URL/page ($$Return value). I have tried this:@If(newPetition_address1 = Null; @SetField(“Error_address1”; “Enter address”); @Success);

@Command([RunAgent]; “(crmd)”);

@Command([FileSave]);

@Command([FileCloseWindow]);

Only the last 2 commands execute. So I also tried this: @PostedCommand([FileSave]);

@If(newPetition_address1 = Null; @SetField(“Error_address1”; “Enter address”); @Success) and run the agent from WebQuerySave. Where the result is the agent runs first and then the rest. If I include the @PostedCommand([FileCloseWindow]); as well then again only the FileSave and FileCloseWindow commands execute.

What do I need to do in order for the:

1/ field validations to execute first

2/ run the agent

3/ save

4/ close-open URL

Whats the @commands order of execution? I realise that RunAgent executes immediately, @Postedcommand executed last!

You help will be much appreciated.