[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 832
  • Last Modified:

PostSave - @MailSend Help

I can't seem to get this to work.  

The Field DTL_Node is derived from a DbLookup based on the value of another field.  I need to email notifications to selected persons depending on the value of DTL_Node, including the scenario where the Dblookup fails.

Syntactically this is correct but the email notifications don't work.

Synopsis...If TktStatus is "Closed"...end.   If Document is new...process the @If statement and send emails based on value of DTL_Node field.  Finally if If DTL_Node DbLookup fails (causing an error), send email.

Thanks in advance!!!

Here is my PostSave event Formula:  

@If(TktStat="Closed";"";@IsNewDoc;@If(DTL_Node="dknas1" | DTL_Node="grdcta" | DTL_Node="grdctb" | DTL_Node="dknas2" | DTL_Node="dknas3" | DTL_Node="whpscc";@MailSend ("Roger1/EMPL/NY/MyComp"; ""; ""; "A New Trouble Log has been created."; "A Trouble Log has been created by...  ";Orig:"  for Port ": DTL_DktDest : @NewLine : "Click here to view the Trouble Log  ----->     ";[IncludeDoclink]); DTL_Node="qns1" | DTL_Node="bnx" | DTL_Node="wst500" | DTL_Node="wst2002" | DTL_Node="wst2000" | DTL_Node="tandem2" | DTL_Node="tandem" |DTL_Node="mid1" |DTL_Node="mid2" | DTL_Node="gmtr2" | DTL_Node="pearls";@MailSend ("Roger2/EMPL/NY/MyComp"; ""; ""; "A New Trouble Log has been created."; "A Trouble Log has been created by...  ";Orig:"  for Port " : DTL_DktDest : "." : @NewLine : "     Click here to view the Trouble Log  ----->     ";[IncludeDoclink]);@IsError(DTL_Node);@MailSend ("Roger3/EMPL/NY/MyComp"; ""; ""; "A New Trouble Log has been created."; "A Trouble Log has been created by   "; Orig : "": @NewLine: "Note: The Node Lookup has failed for this circuit" : @NewLine :"     Click here to view the Trouble Log  ----->      ";[IncludeDoclink]);"");"")
0
rognyn
Asked:
rognyn
  • 5
  • 4
  • 2
8 Solutions
 
HemanthaKumarCommented:
Is this DTL_Node returning multiple values ? If so the comparison in @IF statement is invalid.. you have to use @IsMember function to check if the value is in the list.

Second don't code the @mailsend in this if condition rather extract/set a flag value indication what mail it hass to send..

then use another @if condition to look for this flag and then send mail appropriately

eg;

@If(TktStat="Closed";@return("");"");

MailFlag := @If(DTL_Node="dknas1" | DTL_Node="grdcta" | DTL_Node="grdctb" | DTL_Node="dknas2" | DTL_Node="dknas3" | DTL_Node="whpscc"; 1; DTL_Node="qns1" | DTL_Node="bnx" | DTL_Node="wst500" | DTL_Node="wst2002" | DTL_Node="wst2000" | DTL_Node="tandem2" | DTL_Node="tandem" |DTL_Node="mid1" |DTL_Node="mid2" | DTL_Node="gmtr2" | DTL_Node="pearls"; 2 ;@IsError(DTL_Node);3;"")

@if(MailFlag =1;
@MailSend ("Roger1/EMPL/NY/MyComp"; ""; ""; "A New Trouble Log has been created."; "A Trouble Log has been created by...  ";Orig:"  for Port ": DTL_DktDest : @NewLine : "Click here to view the Trouble Log  ----->     ";[IncludeDoclink]);
MailFlag =2;
@MailSend ("Roger2/EMPL/NY/MyComp"; ""; ""; "A New Trouble Log has been created."; "A Trouble Log has been created by...  ";Orig:"  for Port " : DTL_DktDest : "." : @NewLine : "     Click here to view the Trouble Log  ----->     ";[IncludeDoclink]);
MailFlag =3;
@MailSend ("Roger3/EMPL/NY/MyComp"; ""; ""; "A New Trouble Log has been created."; "A Trouble Log has been created by   "; Orig : "": @NewLine: "Note: The Node Lookup has failed for this circuit" : @NewLine :"     Click here to view the Trouble Log  ----->      ";[IncludeDoclink]); "" )



~Hemanth
0
 
Andrea ErcolinoCommented:
mmm, something wrong in your formula, rognyn
Your second @If formula is currently never executed, because you have it in the PostSave event and <<@IsNewDoc>> always fails... so no message is sent
0
 
Andrea ErcolinoCommented:
You should move it to the QuerySave event, or replace the <<@IsNewDoc>> test with something like <<Executed = "">>
and put a corresponding instruction <<FIELD Executed := "1";>> at the end of the formula
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
HemanthaKumarCommented:
That is already taken care in the modified script..
0
 
Andrea ErcolinoCommented:
I looked at your formula carefully, before posting this, but I'm still not able to see how you take care of executing the @MailSend only if @IsNewDoc or just only once...

(maybe I'm tired -- my work day is ending :-)
0
 
HemanthaKumarCommented:
I meant I removed the NewDoc check so that the formula can send mails ..

But sending it for only once or several depends on the state TktStat
0
 
rognynAuthor Commented:
First let me say thanks for all your help...
To answer some questions...the DTL_DktDest field is an editable "Use View Dialog for Choices" field.  Since it is editable the user may manually type into this field if the "proper" selection is not on the list.  The computed when composed, DTL_Node field,  uses a DbLookup based on the value of the DTL_DktDest field, when the data is typed, the Lookup fails.  So I need to account for this and send mail accordingly.  
The DTL_Node does not return multiple values, but can return a value of  "ERROR: Servor error: Entry not found in index".

I felt I needed to use @IsNewDoc because I only want e-mails sent upon creation of a new document, not upon editing or if the TKt_Stat field value is "Closed".

..as for the "progress" I'm making....I still need some assistance.  For ease...I copied and pasted the Formula "as is" into the "QuerySave" event and got 2/3 functionality..that is to say if the value of Dtl_Node is on the first or second "list comparison",  emails are sent correctly.  If the vale of Dtl_Node is an "error"...then e-mails are not being sent.  
0
 
Andrea ErcolinoCommented:
<<@IsError( field )>> check only for an <<@Error>> value in the field (it's generated by Notes or by you), not a string beginning with the "ERROR" word!

You should put the <<@Error>> value in the DTL_Node field (based upon your condition) before evaluating the <<@IsError( DTL_Node )>> for it to work properly.

Otherwise, replace <<@IsError( DTL_Node )>> with <<@Begins( DTL_Node; "ERROR" )>>
0
 
HemanthaKumarCommented:
rognyn,

Use @IsError to probe the dblookup error... and then proceed

Secondly to trigger this only when it is newdoc..

Copy the formula into querysave.. if it is not feasible. Create a computed for display field with following formula

@if( @isNewDoc & @isDocBeingSaved; ""; @Return(0));
...Paste the mailsend formula here


0
 
Andrea ErcolinoCommented:
In your las comment you said that the DTL_Node is computed when composed? are you sure? I think it should be computed. Please post the formula.

In the meanwhile, I think your formula for the DTL_Node resembles the following
---
try := @DbLookup( "":"NoCache"; server:database; view; value; column );
@If( @IsError( try ); "ERROR: Servor error: Entry not found in index"; try );
---
If so, then you have two choices:
1. if DTL_Node is shown and you do want the "ERROR:..." message displayed, then
     a. move the DTL_Node to an always hidden paragraph and replace the "ERROR:..." message with <<@Error>>
     b. where was the DTL_Node now put a Computed for display field, like <<DTL_Node1>>, with formula <<try := DTL_Node; @If( @IsError( try ); "ERROR: Servor error: Entry not found in index"; try )>>, for displaying DTL_Node as you like
2. if DTL_Node is (already or easily) hidden, then replace the "ERROR:..." message in with <<@Error>>
0
 
rognynAuthor Commented:
Thanks again for everyones help....the Form works fine now.  The choosen fix ( as I'm sure...there was more than 1 way to fix this trouble )was to copy the SendMail formula in to the QuerySave Event and used  @Begins(DTL_Node;"ERROR") to check for the lookup failure.   All emails are correctly sent,  under the correct conditions, and they are sent only when the Document is "new.


I will split the points since I sure that HeMan's fix was also correct...initially I choose the other since copy and pasting the original formula included less editing/typing.

Thanks to both of you!!!!

Roger!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now