Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Easy Question? Check @IF Formula Syntax

Posted on 2005-04-11
8
Medium Priority
?
233 Views
Last Modified: 2013-12-18
Experts,

The following code sends the emails, but does not update the hidden field [EditSentFlag] to Yes.  By default, the document is set to EmailSentFlag=No.  Only if the field BDCEmail is checked, then emails are sent (there are 3 values for BDCEmail).  The values are retrieved from hidden fields, at the top of the form, computed, eacj using @GetProfileField("DbProfile";"BDC3")

Since there will be future edits on this main document -- I only want the email to be sent the very first time, and only if the specific field is checked (at least half of the time, this alert will not be sent from this particular form.

What is wrong with my @If statement that is it not allowing my EmailSentFlag to be updated with YES if the condition is true?  Also, please verify that all of these conditions can be true -- or should I be using Case Select?  (confused??)

@If(EmailSentFlag="No" & @Contains(BDCEmail;"BDC1"); @MailSend(BDC1;DbAdmin;Null;"New Literature Submitted";"New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";Null;[IncludeDoclink]);
@SetField(EmailSentFlag;"Yes"));
@If(EmailSentFlag="No" & @Contains(BDCEmail;"BDC2"); @MailSend(BDC2;DbAdmin;Null;"New Literature Submitted";"New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";Null;[IncludeDoclink]);
@SetField(EmailSentFlag;"Yes"));
@If(EmailSentFlag="No" & @Contains(BDCEmail;"BDC3"); @MailSend(BDC3;DbAdmin;Null;"New Literature Submitted";"New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";Null;[IncludeDoclink]);
@SetField(EmailSentFlag;"Yes"))

Please rush -- I know, past couple of days all of my Qs have been rush rush :(

Thanks in advance,
AliciaVee
0
Comment
Question by:AliciaVee
  • 4
  • 4
8 Comments
 
LVL 31

Expert Comment

by:qwaletee
ID: 13758078
First, easier if you structure the format of the code:

@If(
    EmailSentFlag="No" & @Contains(BDCEmail;"BDC1");
        @MailSend(
            BDC1;DbAdmin;Null;"New Literature Submitted";
            "New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";
            Null;[IncludeDoclink]
        );
    @SetField(EmailSentFlag;"Yes")
);

@If(
    EmailSentFlag="No" & @Contains(BDCEmail;"BDC2");
        @MailSend(
            BDC2;DbAdmin;Null;"New Literature Submitted";
            "New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";
            Null;[IncludeDoclink]
        );
    @SetField(EmailSentFlag;"Yes")
);

@If(
    EmailSentFlag="No" & @Contains(BDCEmail;"BDC3");
        @MailSend(
            BDC3;DbAdmin;Null;"New Literature Submitted";
            "New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";
            Null;[IncludeDoclink]
        );
    @SetField(EmailSentFlag;"Yes")
)

0
 
LVL 31

Expert Comment

by:qwaletee
ID: 13758173
Now, this may be your problem.  You misunderstand the way @If works.  You have three separate @If statements.  In each case, you have three parameters:

1) condition (based on EmailSentFlag=No and some content in BDCEmail field
2) mailsend
3) setfield

So, if I can paraphrase:
@If(  condition    ;   mailsend    ; setfield)

I THINK you are assuming that if condirion is true, both mailsend and setfield get executed, i.e., each if will do one of two things:
1) it will be skipped if the condition is false
2) if teh condition is true, it will send a message AND it will set the field to Yes

That's not so.  A 3-parameter @If is really

@If(1;2;3) -- 1 is the condition, 2 is what to do if true, 3 is "else" (i.e., what to do if condition is false.

So, I think you really wanted something different...

@If(
    EmailSentFlag = "Yes";
        @Return(FAKE_STATEMENT_SKIP_ALL_THIS);
    BDCEmail = "BDC1";
        @MailSend(....);
    BDCEmail = "BDC2";
        @MailSend(....);
    BDCEmail = "BDC3";
        @MailSend(....);
    @Return(
        @Prompt([OK]; "Error [ELSE STATEMENT]"; "Unexpected condition -- EmailSentFlag=No and BDCEmail does notmatch known values BDC1/2/3")
    )
);
FIELD EmailSentFlag := "Yes"; REM "We ALWAYS set this -- either it was already Yes and the @Return(FAKE) stopped the rest of the formula, or one of the three BDC statements matched and e-Mail was sent and then it got here, or @Return(@Prompt) stopped the rest of the formula.  So, if we got here, a message WAS sent.";
0
 

Author Comment

by:AliciaVee
ID: 13758244
qwaletee,

Wow!  Great explanation -- thank you thank you!  Yep -- you were right in the way my little head was thinking.  It is because I have some VBA experience with MS Access dbs -- I get confused and am having a hard time trying to stay focused on Notes, and that language.  But with your help (and other EEs) I am getting there.  Your explanation of how this is supposed to work makes excellent sense.  Stuff I can't learn in books :(

I will try as you suggested (and yes, I really have to learn how to write better code layout.  Sometimes when I try to enter in my code window, I get an error like I'm not supposed to split certain parts of the code -- still trying to figure that out).

Anyway -- one question.  For the @Return part...am I supposed to enter what you have?  (FAKE_STATEMENT_SKIP_ALL_THIS);

Okay...will try that.
;)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:AliciaVee
ID: 13758306
qwaletee,

Okay, I added your code -- as is -- no changes.  the EditSentFlag is not updating to Yes.  Also, only one email gets sent.  So, if in BDCEmail FIELD -- there are 3 checked boxes, 3 emails should be sent.  The BDCEmail values are coming from hidden fields that are populated based on a profile doc.  In my previous code, that part was working, but the EditFlag was not getting updated to yes.

Help.....
0
 

Author Comment

by:AliciaVee
ID: 13764374
qwaletee ,

Okay -- I've tweaked this a little.  Instead of a hidden field, I am using a combo drop down list to select whether an email should be sent or not Yes or No.

Now, it is working and I have the option to change it to NO -- if I have to go back into the document to make changes (leveraging your other solution you provided for the request form in another post.  This is actually the Main parent document -- the other document is the response doc).

Anyway, now what happens is that only one email gets sent, even if I check off all three choices (each choice is a specific person in a department -- and not all 3 should be informed of new literature).

This is what I have in PostSave event:

@If(
    EmailSentFlag = "No";
        @Return(FAKE_STATEMENT_SKIP_ALL_THIS);
    BDCEmail = "BDC1";
        @MailSend(BDC1;DbAdmin;Null;"New Literature Submitted";
            "New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";
            Null;[IncludeDoclink]
);
    BDCEmail = "BDC2";
        @MailSend(BDC2;DbAdmin;Null;"New Literature Submitted";
            "New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";
            Null;[IncludeDoclink]
);
    BDCEmail = "BDC3";
        @MailSend(BDC3;DbAdmin;Null;"New Literature Submitted";
            "New Literature has been submitted by "+ DocAuthor+@NewLine+"Please click the link to view the submission and take the required action for group notification --> ";
            Null;[IncludeDoclink]
);
    @Return(
        @Prompt([Ok]; "Error [ELSE STATEMENT]"; "Unexpected condition ")
    )
)

By the way, I'm not sure if I am supposed to edit/add/remove the [ELSE STATEMENT] text above -- or is that part of the code?

AliciaVee
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 13768690
AliciaVee,

> Anyway -- one question.  For the @Return part...am I supposed to enter what you have?  
> (FAKE_STATEMENT_SKIP_ALL_THIS);

In VB (and LotusScript), you can have an empty executable section of an IF or ELSE.  Not so with @If. Therefore, you have to put in something.  I put in a fake variable, which, since it holds no value, evaluates to an empty string, which effectively has no action.  So, the following are equivalents:

If someCondition Then
Else
    Print "false"
End If

@If(someCondition;
    EMPTY_CLASE_THIS_IS_A_FAKE_VARIABLE;
  @Prompt([ok]; ""; "false")
)


The @Return cuases teh formula to stop evaluating immediately.

- qwaletee
0
 
LVL 31

Accepted Solution

by:
qwaletee earned 2000 total points
ID: 13768700
If you realy do need three e-Mails, then you either need three @Ifs (consecutive, not nested). I woudl work it something like this:

@If(EmailSentFlag = "Yes"; @Return(NO_MORE_MESSAGES); CONTINUE_WITH_MESSAGES);

@If( firstMatchCondition; @MailSend; NO_SEND_ON_FALSE);
@If( secondMatchCondition; @MailSend; NO_SEND_ON_FALSE);
@If( thirdMatchCondition; @MailSend; NO_SEND_ON_FALSE);

FIELD EmailSentFlag := "Yes"; REM "We alsways do this -- but I don't know if this is the irght way, because what if no e-Mails were sent?  Or, what if the first condition matches now, but a second later?  Do we really need three email flags?  You decide."
0
 

Author Comment

by:AliciaVee
ID: 13869173
qwaletee,

You bring up a good point -- does it make sense have this many flags?  Well, for this particular need, there are really 3 different departments that get notified, but will keep it in mind for futuere apps.

thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question