Incorrect data type for operator or @Function: Number expected

Hi Everyone,

I have a button on a form which used to work very well until I added some code to it from another button.

The code I have added is below between *** - Code … was added - ***

Now on the document when this button is pressed in the comments field (QCApprovalComments and QCApprovalCommentsDisplay) fails with the error in the subject. They are both text fields and nothing has changed.

The only difference with this code is that I put an @IF statement in because if comments from the dialog box is blank then I don’t want email to be generated, if there are comments I want email generated.

Does anyone have any ideas why I’m getting this error now?

Thanks,

Hayley

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

Name:=@Name([CN];@UserName);

@Command([ViewRefreshFields]);

*** - Code below was added - ***

@DialogBox(“QCHiddenDialog”;[AutoHorzFit]:[AutoVertFit]:[NoNewFields];“Reviewers Comments”);

@Command([ViewRefreshFields]);

@If(QCApprovalComments=“”;@Return(“”); “”);

@MailSend(CreatedBy;“”;“”;“QC Approvers Comments for MARACQ Bid No. “+FileNumber+” for " +Client+ " " + Region;”";

+Remarks +@NewLine+@NewLine+

“Approval Comments” +@NewLine+@NewLine+QCApprovalComments+@NewLine+@NewLine+

“Link to Document (note - If you are working on another server” +@NewLine+"this document could take up to 60 minutes to replicate ) → ";[IncludeDoclink])|

@Prompt([Ok];“Sent Confirmation”;“Your comments have been emailed - Thank you”)|

@SetField(“Comments2”;“Yes”)|

newComments:=QCApprovalComments + " - " + Name|

FIELD QCApprovalCommentsDisplay:= @If( @Elements(QCApprovalCommentsDisplay)=0; newComments; QCApprovalCommentsDisplay : newComments )|

@SetField(“QCApprovalComments”;“”);

*** - Code above was added - ***

FIELD QCToggle:=QCToggle;

FIELD QCHSE_SignOff:=QCHSE_SignOff;

FIELD QC_signoffsrequired:=QC_signoffsrequired;

@SetField(“QCToggle”;“Yes”);

@SetField(“QCHSE_SignOff”;“Yes”);

@SetField(“QC_signoffsrequired”;“”);

space:= " ";

comma:=“,”;

month:=@Select(@Month(@Today);“January”;“February”;“March”;“April”;“May”;

“June”;“July”;“August”;“September”;“October”;“November”;“December”);

day:=@Text(@Day(@Today));

year:=@Text(@Year(@Today));

date:=day + space+ @Left(month;3) + space + comma + space + year;

FIELD ModifyDate:=date;

newSignOff:= Name + " on " +ModifyDate;

FIELD QC_signoffs:= @If( @Elements(QC_signoffs)=0; newSignOff; QC_signoffs : newSignOff );

@Command([ViewRefreshFields]);

@Command([FileSave]);

QC_Send_To := AllQC;

QC_Copy_To := “”;

Blind_Copy_To := “”;

QC_Email_Subject := “MARACQ Bid No. " + FileNumber + " for " + Client + " " + Region + " : Has Been QC Approved”;

Remark := “”;

host := @GetProfileField( “dbProfile”; “FQDN” );

bid_db := @WebDbName;

bid_view := “-”;

bid_unid := @Text( @DocumentUniqueID ) ;

URL_Link := “http://” + host + “/” + bid_db + “/” + bid_view + “/” + @Left( FileNumber; 13 ) + “?Edit”;

QC_Email_Body := @NewLine + @NewLine + “This bid has now been QC Reviewed.” + @NewLine + @NewLine + “Blackberry/Web users ONLY: Please follow the URL link to review and approve the contract prices.” + @NewLine + @NewLine + URL_Link + @NewLine + @NewLine + "Notes Client ONLY: Please follow the doclink to review and approve the contract prices. " + @NewLine + @NewLine;

@Command([ViewRefreshFields]);

@If(

ALLQCToggle=“Yes”;

@SetField(“QCStatus”;“Bid Approved”)|@MailSend( QC_Send_To ; QC_Copy_To ; Blind_Copy_To; QC_Email_Subject ; Remarks ; QC_Email_Body ;[IncludeDoclink])

|@PostedCommand([FileSave]) & @PostedCommand([FileCloseWindow]);@PostedCommand([FileSave]) & @PostedCommand([FileCloseWindow]))

Subject: Incorrect data type for operator or @Function: Number expected

I can’t say for certain, I didn’t test this, but this line looks very odd:@If(QCApprovalComments=“”;@Return(“”); “”);

So, if the QCApprovalComments field is blank, return nothing, otherwise, nothing?

Try:

@If(QCApprovalComments=“”;@Return(“”);

or

@If(QCApprovalComments=“”;@Return(“”); 1);

Subject: Incorrect data type for operator or @Function: Number expected

Hello Generic Notes Developer,

Thank you for your response.

I have altered the code to have:

@If(QCApprovalComments=“”;@Return(“”);

@MailSend(CreatedBy;“”;“”;“QC Approvers Comments for MARACQ Bid No. “+FileNumber+” for " +Client+ " " + Region;”";

+Remarks +@NewLine+@NewLine+

“Approval Comments” +@NewLine+@NewLine+QCApprovalComments+@NewLine+@NewLine+

“Link to Document (note - If you are working on another server” +@NewLine+"this document could take up to 60 minutes to replicate ) → ";[IncludeDoclink])|

@Prompt([Ok];“Sent Confirmation”;“Your comments have been emailed - Thank you”)|

@SetField(“Comments2”;“Yes”)|

newComments:=QCApprovalComments + " - " + Name|

FIELD QCApprovalCommentsDisplay:= @If( @Elements(QCApprovalCommentsDisplay)=0; newComments; QCApprovalCommentsDisplay : newComments )|

@SetField(“QCApprovalComments”;“”));

If I enter text in the dialog box it emails me and the text within the email is fine and readable, but on the document in the QCApprovalCommentsDisplay field it still errors with the subject line above…

Any other ideas?

Subject: Incorrect data type for operator or @Function: Number expected

Ummm what is with the pipe (|) characters? See the red items in the code below:

Am I missing something? It looks like things are one big string to me or maybe things are "or"ed together? I’ve just never seen this before, maybe it’s perfectly valid.

The IF statement Generic Notes Developer pointed out, I use all the time - I don’t think that’s the problem).

@MailSend(CreatedBy;“”;“”;“QC Approvers Comments for MARACQ Bid No. “+FileNumber+” for " +Client+ " " + Region;”";

+Remarks +@NewLine+@NewLine+

“Approval Comments” +@NewLine+@NewLine+QCApprovalComments+@NewLine+@NewLine+

“Link to Document (note - If you are working on another server” +@NewLine+"this document could take up to 60 minutes to replicate ) → ";[IncludeDoclink])|

@Prompt([Ok];“Sent Confirmation”;“Your comments have been emailed - Thank you”)|

@SetField(“Comments2”;“Yes”)|

newComments:=QCApprovalComments + " - " + Name|

FIELD QCApprovalCommentsDisplay:= @If( @Elements(QCApprovalCommentsDisplay)=0; newComments; QCApprovalCommentsDisplay : newComments )|

System was much happer when I changed the code to:

@SetField(“Comments2”;“Yes”);

newComments:=QCApprovalComments + " - " + Name;

FIELD QCApprovalCommentsDisplay:= @If( @Elements(QCApprovalCommentsDisplay)=0; newComments; QCApprovalCommentsDisplay : newComments );

@SetField(“QCApprovalComments”;“”);

I see there are more down in the @if in the end. Looks like you might be missing an @Do down there.

Subject: RE: Incorrect data type for operator or @Function: Number expected

They are being ORed – which would be a weird but borderline legitimate approach for chaining commands IF AND ONLY IF everything being chained with the OR operator (the pipe character) had a numerical return. (The use of & to chain statements in an @If was common before @Do was added to the language.) The problem is that not everything has a numerical (status/success) return, and since we no longer need to work around a missing @Do, there is no longer any good reason to use Boolean operators to chain formula language statements.