Still can't figure out @PostedCommand & @Command

Although reading so much posts and topics from help, I still can’t figure out what is the difference between @PostedCommand and @Command.

I got an application (run on both web and notes) with two buttons:

  1. Save as Draft

  2. Save and Submit

For the button [Save as Draft], there is no need to validate fields, just save the document:

Here is the coding on :Click -

@SetField(“NeedValidate”;“0”);

@PostedCommand([FileSave]);

@PostedCommand([FileCloseWindow])

I put some JS codes at onSubmit event for fields validation.

I hide a field called NeedValidate and set it to “0” or “1” to determine if validation is required at onSubmit event.

On Notes client, the above formulas on the button [Save as Draft] works fine where no validation executed and the doc is saved.

However if I changed @PostedCommand to @Command,

ie.:

@Command([FileSave]);

@Command([FileCloseWindow])

If I click the button [Save as Draft], it will prompt a dialog box to ask for save or not save.

Could someone enlighten me what is happening?

Subject: Still can’t figure out @PostedCommand & @Command

@postedcommands will always execute at last even if they are written in middle of set of formulas. @commands will execute in the order without waiting for other commands to finish.

So, in the first example “NeedValidate” is set to “0” first and then the save and close commands executes.

In second example, after setting the field value, both the save and close happens at same time and as the doc is updated but not save prompts for save dialog.

–Phani

Subject: RE: Still can’t figure out @PostedCommand & @Command

Thanks phani again,

Just wanna make sure is that meant the two statements using @Command will execute at the same time while @PostedCommand will execute in order (at last after other formulas).

It seems to me that @Command are not execute in order (save and then fileclose) but at the same time after other commands, thus causing my doc not saved at the time of fileclose thus prompting dialog box.

If that is true, it will always be problem of using:

@Command([FileSave]);

@Command([FileCloseWindow])

since they are run at the same time and will always prompt user a dialog box.

But it is very strange that I have tested another scenario, I add another field ABC with default value “1”:

And .Click for the button:-

@SetField(“ABC”;“1”);

@Command([FileSave]);

@Command([FileCloseWindow])

On clicking the button, it simply save and close the window.

If I change the first line to:

@SetField(“ABC”;“0”);

On clicking the button, it prompt a dialog box for saving.

If I click the Cancel in the dialog box, then it returns to my doc and again I click the Save button, it could simply save&close the window without prompting dialog box.

What is happening???

But using @PostedCommand, click the button becomes normal as no dialog box will be prompted.