@Prompt([YesNo] - can't get all functions to execute

In our Calendar Db, we have a Cancel button on our “Class” form programmed with the formula below. When a user clicks “Yes”, only the first command on the list executes (EditDocument), but beyond that, none of the remaining commands execute. Can someone tell me what I am doing wrong here? Thanks!

Subject := “Training Class Request Cancelled” ;

Message := “The training class below has been cancelled due to minimum participant level not being met. Please check the database for future classes, or contact your area Training Specialist. We are sorry for any inconvenience this may have caused you.”;

var:=@Prompt([YesNo]; “Verify Cancellation”;“Are you sure you want to cancel this class?”);

@If(var=1;

@Command ([EditDocument] ; “1”) ;

@SetField (“Cancelled” ; @Today) ;

@MailSend (@Unique (ParticipantTL) ; “” ; “” ; Subject ; Message ; “”) ;

@Command ([ToolsRunMacro] ; “(Remove Trakker Doc)”) ;

@Command ([FileSave]);“”)

Subject: @Prompt([YesNo] - can’t get all functions to execute

The problem is that you can’t execute multiple commands within and @If like you’ve got it there. If you have look at the help for @If, you’ll be able to see that your @If is saying:

If var = 1 then edit the document, else if @SetField(“Cancelled”;@Today) then @MailSend, elseif @Command([ToolsRunMacro]) then @Command([FileSave]) else do nothing.

In order to get an @If to execute multiple commands if the condition is true, then you need to change it to this (note the @Do() surrounding all your commands):

@If(var=1;

@Do(@Command ([EditDocument] ; “1”) ;

@SetField (“Cancelled” ; @Today) ;

@MailSend (@Unique (ParticipantTL) ; “” ; “” ; Subject ; Message ; “”) ;

@Command ([ToolsRunMacro] ; “(Remove Trakker Doc)”) ;

@Command ([FileSave]));“”)

Alternatively, you can do it this way:

@If(var=1;NULL;@Return(“”);

@Command ([EditDocument] ; “1”) ;

@SetField (“Cancelled” ; @Today) ;

@MailSend (@Unique (ParticipantTL) ; “” ; “” ; Subject ; Message ; “”) ;

@Command ([ToolsRunMacro] ; “(Remove Trakker Doc)”) ;

@Command ([FileSave])

This basically says, if the user clicks ‘Yes’, don’t do anything yet, but if they click no, stop execution of the rest of the formula. If they clicked yes then the rest of the formula will then execute. I usually do it this way to avoid the confusion of having a bunch of commands within an @If and a @Do

Hope this helps,

Emily.

Subject: @Prompt([YesNo] - can’t get all functions to execute

Beck,

I tried this part of your code and it worked like a charm. Press Yes and HI is wrote in the field, press No and it stops.

var:=@Prompt([YesNo]; “Verify Cancellation”;“Are you sure you want to cancel this class?”);

@If(var=1; @Command ([EditDocument] ); “1”) ;

@SetField(“ProjectNum”;“HI”)

Have you tested this code or a portion on a test form?? Perhaps you can try @success.

I usually use the following code which is just a reverse of what you used.

@If(var = 0; @Return(“”);“”);

Sorry can’t be of more help,

Teri