I haven't seen too many "red boxes of death" since the later versions of R5 came out, and almost none in V6.x. Well, I found a way to get one to appear:
The following code, which is executed in an action button on a response document, produces a "Object handle is invalid" red box every time in my Notes 6.5.2 client:
FIELD history_mfg:=history_mfg;
FIELD created:=created;
date:= @Text(@Now);
name := "";
SUBJ := "<< Quote Request Notification From MFG - Project Ref# " + req_num + " >>";
BODY := SUBJ + @NewLine + "Request #: " + @Text(Incremented) + "-" + req_num + @NewLine + "Piece Price: " + @Text(piecepc) + @NewLine + "Tooling Price: " + @Text(tooling) + @NewLine + "Comments Or Exceptions: " + body_notes + @NewLine + "See Link >> ";
@If(@IsNewDoc;@Prompt([Ok];"Notification!";"You Must Save The File Before You Can Initiate The Request.");@Do
(@If(@Prompt([YesNo]; "Send Memo?"; "A memo will be sent to Sales to notify them of your Quotation Response."); @Do(
@Set("name";@ProperCase(@Name([CN];@PickList( [Name] : [Single] ))));
@MailSend(name;"";"";SUBJ;"";BODY;[IncludeDoclink]);
@Prompt([Ok]; "Notification!"; "Your message has been summited.");
@SetField("history_mfg";history_mfg + @NewLine + "Your Sales Notification Was Sent To " + name + " On: " + date);
@SetDocField ( $Ref; "SalesPublishDate"; @Now );
@Command ( [ViewRefreshFields] );
@Command ( [FileSave] );
@Command ( [CloseWindow] )
);
@Failure(@Prompt([Ok]; "Operation"; "Canceled")))))
The cause or instigator of the red box turned out to be the @SetDocField function. When I take it out, the code runs fine. I tried moving the call to @SetDocField around, but the same red box always appears. Not sure why. To get around this problem, I replaced @SetDocField with @Command ( [ToolsRunMacro]; "Set Parent" ), which works just fine.