"Incorrect Data Type Error" but Document Is Closed

I have a submit button on a form that checks some things, updates a field, saves the document and then executes a mail send. I receive the message “Incorrect Data Type For Operator Or @ Function: Text Expected” at the end of all this. The problem is that all the code is executed correctly and the document is closed before the message is sent. How can I tell which field that is causing the problem with the document closed?

@SetField(Issued;@Now)&

@If(DueDate <= @Adjust(Issued;0;0;13;0;0;0);

@Prompt([Ok];“Warning”;“The Due Date must be at least 2 weeks later than the Date Issued. The Due Date you entered has been deleted. Please enter a valid Due Date and click on submit again.”) & @SetField(“DueDate”;“”);

@Command([FileSave])&

@Command([FileCloseWindow])&

@SetField(“Status”;“Open/Submitted”) &

@SetField(“DocAuthor”;“”)&

@MailSend(“John Doe”;“”;“”;“Document has been submitted.”;“A document has been submitted, please review by clicking on the icon below.”;[IncludeDoclink]))

Subject: “Incorrect Data Type Error” but Document Is Closed

It’s not a field causing the problem; it’s your @MailSend function. Read about this function in the Domino Designer help. See what value you’ve supplied for each of the arguments. There’s one that’s supposed to be text, but isn’t?

Who told you that you should use & to conjoin statements? Don’t do that. Use “;” instead. If you need multiple statements in an @If, use @Do. Read about that too. And tell the person who taught you to stop teaching, please.

Why are you modifying fields after the document has been saved? How do you expect these changes to get saved?

Are you assuming that the just-saved document will be selected in a view after you close the window? Not a safe assumption. Fortunately for you, the close window doesn’t happen until the formula is complete.