I have a problem with this error message appearing when the button is used: "Incorrect data type for operator or @Function: Number Expected"
Everything works fine - it just pops up the error message when "Needs Checking" is selected
Code:
@Command( [EditDocument]; "1" ); FIELD STAT := @Prompt([OkCancelList]; "Select and Action"; "Checking Status?"; "STAT"; "Needs Checking" : "Needs Amending" : "Checked" ); @If(STAT="Needs Checking";@SetField("USER";@Name([CN];@UserName)) & @SetField("REF";@Unique) & @Command([FileSave]) & @Command( [EditDocument]; "0" ) & @Command([Folder];"Checking";"1") & @Command([CloseWindow]); @Command([FileSave]) & @Command( [EditDocument] ; "0" ) & @Command([Folder];"";"1") & @Command([CloseWindow]))
Thanks :)
The &
is a logical operator and not for concatenating of commands. That way you do something like
ResultOfCommand1 & ResultOfCommand2 & ResultOfCommand3
This is a comparison and returns true or false. If one of the results is not numerical, then you get the error.
Use "@Do" to concatenate more than one command in your if:
@Command( [EditDocument]; "1" );
FIELD STAT := @Prompt([OkCancelList]; "Select and Action"; "Checking Status?";
"STAT"; "Needs Checking" : "Needs Amending" : "Checked" );
@If( STAT="Needs Checking";
@Do( @SetField("USER";@Name([CN];@UserName));
@SetField("REF";@Unique);
@Command([FileSave]);
@Command( [EditDocument]; "0" );
@Command([Folder];"Checking";"1");
@Command([CloseWindow]) );
@Do( @Command([FileSave]);
@Command( [EditDocument] ; "0" );
@Command([Folder];"";"1");
@Command([CloseWindow])) )
But this is still "bad code" as it contains a lot of duplicate code. I would do it like this (still not best code, but better):
@Command( [EditDocument]; "1" );
FIELD STAT := @Prompt([OkCancelList]; "Select and Action"; "Checking Status?";
"STAT"; "Needs Checking" : "Needs Amending" : "Checked" );
@If( STAT = "Needs Checking";
@Do( @SetField("USER";@Name([CN];@UserName));
@SetField("REF";@Unique);
@Set( _folderName; "Checking" )
); "" );
@If( @Command( [FileSave] ); "" ; @Return( "" ) );
@Command([Folder];_folderName;"1");
FIELD SaveOptions := "0";
@Command([CloseWindow]);
e.g.: I check if the document can be saved (Field validation, Continue = Fals in QuerySave... If not: Stop processing.
Then I just put the things in the @If, that are different for both cases.
Setting EditMode to "0" is not necessary as you immediately close the document after. To prohibit a "Do you want to save your changes" I set SaveOptions to "0" (this will not be saved in document). The foldername is in a variable, so that @Command( [Folder] ; ... ) can use it.