@Failure not working?

I’ve got a validation formula giving me a migraine. I KNOW it evaluates to “True”, but my @Failure is not executing. When I replace the @Failure with an @prompt, I see the messge.

Just to try a few things, I put an @Failure as both the 1st and last lines of the formula (with no @if around them). The first one does NOT execute, but he last one does.

Anyone know what the heck is going on with this?

Subject: Perhaps it might help if you posted the code?

Subject: @Failure not working?

@Failure works – there’s got to be something else going on. Can you post the actual formula?

Subject: @Failure not working?

I finally got a formula working, so I guess I’m not too worried about it right now, but I still can’t explain why the @Prompt would execute and the @Failure not.

I’ve not through several iterations of the code, but I’m pretty sure it was:

@If(Outcome=“Won”&NumberFilled=0;@Failure(“You have indicated that this requirement has been ‘won’, but none of the ‘send out’ candidates have been set as hired or placed.”);@Success);

@If(Outcome = “Open” & ApprovedRecruiting != “Yes”;@Failure(“The request must be approved before it can be opened”);@Success);

SOResults := @DbLookup( “”:“NoCache” ; “” ; “InterviewedByClient” ; @Text(@DocumentUniqueID) ; 3 );

@If(@IsError(SOResults);@Return(@Success);@IsDocBeingSaved & @IsMember(“Pending”;SOResults) & (Outcome = “Won” | Outcome = “Lost”);@Failure(“You may not set this requirement to ‘Won’ or ‘Lost’ while there are pending send outs.”);@Success)

Subject: RE: @Failure not working?

Your problem is that you were expecting @Failure to do something. In fact, this function only returns the value of its argument – @Failure(“x”) is equivalent to “x”. It doesn’t print a message, and – this is the key point – it doesn’t halt the execution of your formula.

The message printing occurs based on the return value of the input validation formula. If it’s a number, the save proceeds. If it’s a string, the string is displayed in an error dialog and the save does not occur.

To “error out” of the validation, you should use @Return instead of (or in conjunction with) @Failure, e.g.:

@If(Outcome=“Won”&NumberFilled=0;@Return(@Failure(“You have indicated that this requirement has been ‘won’, but none of the ‘send out’ candidates have been set as hired or placed.”));@Success);

or

@If(Outcome=“Won”&NumberFilled=0;@Return(“You have indicated that this requirement has been ‘won’, but none of the ‘send out’ candidates have been set as hired or placed.”);@Success);

In this specific case, however, you could have kept things simple by just writing one long @If statement, e.g.:

@If(!@IsDocBeingSaved;

@Success;

Outcome=“Won” & NumberFilled=0;

@Failure(“You have …”);

Outcome = “Open” & ApprovedRecruiting != “Yes”;

@Failure(“The request must …”);

@Do(

  SOResults := @DbLookup( "":"NoCache" ; "" ; "InterviewedByClient" ; @Text(@DocumentUniqueID) ; 3 );

  @If(@IsError(SOResults);

     @Success;

  "Pending" = SOResults & Outcome = "Won" : "Lost";

     @Failure("You may not ....");

     @Success

) ) )

Subject: Or code it like this…

@If(@IsDocBeingSaved; “”; @Return(@Success);SOResults := @DbLookup( “”:“NoCache” ; “” ; “InterviewedByClient” ; @Text(@DocumentUniqueID) ; 3 );

@If(Outcome = “Won” & NumberFilled = 0;@Failure(“You have indicated that this requirement has been ‘won’, but none of the ‘send out’ candidates have been set as hired or placed.”); Outcome = “Open” & ApprovedRecruiting != “Yes”; @Failure(“The request must be approved before it can be opened”); @IsError(SOResults); ;@Success; @IsMember(“Pending”; SOResults) & (Outcome = “Won” : “Lost”); @Failure(“You may not set this requirement to ‘Won’ or ‘Lost’ while there are pending send outs.”); @Success)