Scheduled agent acting badly-edit

Agent code below for reference.Assume that docs exist that meet the criteria for the agent.

If the agent is set to run on schedule, no messages are sent.

If I leave the agent set to run on schedule and force it to run from designer (right click agent name - run), no messages are sent.

If I remove the [IncludeDocLinks] parameter and force the agent to run, mail is sent.

If I put the doc links back in but convert the agent to run on event, run on all agents in db, and force it to run from the client (Actions - test), mail is sent and the doc links are intact.

I have other scheduled agents on the same server with similar function code (and doc links) and they run without any problem.

I’m stumped. Any ideas?

TIA

Doug

REM {Send email on the day an item expires or on extension expiration date};

REM {Skip docs not created with the MSDS form. Skip items not expired. Skip hidden docs. Skip if chemical name is blank};

REM {NotifyWhenExpired is a multi-value field containing valid user names. I’ve replaced it with my name, no change in agent behavior};

@If(

Form != “frmMSDSExpiration” ; @Return(“”);

Hide = “Hidden”;@Return(“”);

ChemicalName = “”; @Return(“”);

@Success);

@If(

@Today < @Adjust(ExpirationDate; 0;0;-1;0;0;0); @Return(“”);

@Today = @Adjust(ExpirationDate; 0;0;-1;0;0;0) & ExtendDate = “”; @Success;

@Today = @Adjust(ExtendDate; 0;0;-1;0;0;0) ; @Success;

@Return(“”));

SendTo := NotifyWhenExpired;

cc := “”;

bcc := “Doug Finner”;

remark := “”;

Subject := “MSDS Material: " + ChemicalName + " will Expire Tomorrow”;

Body := "Material: " + ChemicalName + " Lot Code: " + LotBatchCode + " in Location: " + Location + " will Expire effective tomorrow. Please note that the attached link may not work if the item’s status has changed since this email was sent. ";

@MailSend( sendTo ; cc ; bcc ; subject ; remark ; body; [IncludeDoclink] );

SELECT @All

<<>>

For now, I’ve modified the agent in two ways; I’ve pulled the MailSend into the If statement (for some reason, leaving it outside the IF statement caused the system to send messages for everthing that expired; it’s as if it processed the 2nd and third conditions when the 2nd condition was true…).

I’ve switched to sending a Domino URL instead of a doc link.

Side note: we use Coex!Links to send NDLs since we use Exchange/Outlook for mail. It work fine for other scheduled agents so I don’t believe it’s the problem.

I’d still like to know why the doclink is killing the email message if anyone has ideas.

Here’s the revised code:

REM {Send email on the day an item expires or on extension expiration date};

REM {Skip docs not created with the MSDS form. Skip items not expired. Skip hidden docs. Skip if chemical name is blank};

@If(

Form != “frmMSDSExpiration” ; @Return(“”);

Hide = “Hidden”;@Return(“”);

ChemicalName = “”; @Return(“”);

@Success);

SendTo := NotifyWhenExpired;

cc := “”;

bcc := “Doug Finner”;

remark := “”;

Subject := “MSDS Material: " + ChemicalName + " will Expire Tomorrow”;

DbLink := “Notes://NotesKMC/” + @Subset(@DbName; -1) + “/vwExpiredMaterial”;

Body := "Material: " + ChemicalName + " Lot Code: " + LotBatchCode + " in Location: " + Location + " will Expire effective tomorrow. Please make sure Notes is running and you are logged in, then follow this link: " + DbLink;

@If(

@Today < @Adjust(ExpirationDate; 0;0;-1;0;0;0); @Return(“”);

@Today = @Adjust(ExpirationDate; 0;0;-1;0;0;0) & ExtendDate = “”; @MailSend( sendTo ; cc ; bcc ; subject ; remark ; body);

@Today = @Adjust(ExtendDate; 0;0;-1;0;0;0) ; @MailSend( sendTo ; cc ; bcc ; subject ; remark ; body);

@Return(“”));

SELECT @All

Subject: RE: Scheduled agent acting badly-edit

From the Designer help:

[INCLUDEDOCLINK]

… Note This option will only work if the database contains a default view.

Though I haven’t tested this just now, I believe it would be more accurate to say that doesn’t work unless there’s a default view or the current document was obtained from a view. This is why the server agent fails, but an agent set to run on selected documents in a view works.

As far as I know, there’s no difference in how the fieldnames argument works between client and server or different clients; it’s always been the case that if the named item doesn’t exist, the ‘name’ is inserted instead.

Subject: Fine print…it’s always the fine print

THANK YOU! That was it.

A bad day has just been converted into a pretty good day.

I knew it was something stupid, thanks for pointing out the fine detail I was missing.

I’m leaving before I break something else…

Doug

Subject: RE: Scheduled agent acting badly-edit

Perhaps, but this has been part of the documentation since at least R5.0.2 (can’t vouch for anything earlier, but it didn’t claim to be new in that version):

When you use the [IncludeDocLink] flag (described below) to include a link to the current document, you should set the bodyFields parameter to null (“”).

One would think there’d be a reason for that, wouldn’t one?

Subject: RE: Scheduled agent acting badly-edit

I’ll check into that and if I find there’s no basis for it, will suggest the doc team remove it. It may have something to do with merging doclinks from a rich text item you include, with the new doclink, into the same Body item.

Subject: Scheduled agent acting badly

As I understand it, Doug, any body text should go in the “remark” slot and the “body fields” slot is reserved for fieldname literals – and that the body fields parameter is documented to be incompatible with [INCLUDEDOCLINK]. There seems to be a difference, though, in how the client and the server handle the @MailSend with params. It’s as if the client isn’t aware of the incompatibility. (I’ve come by this anecdotally – a lot of people have posted code that works in the client, particularly in the QS, that shouldn’t work according to the documentation.)

Subject: That’s not it either

Scheduled agent code below runs but doesn’t send any email.If I change it to run on event, all docs in db, mail goes, doc links work.

This is mor than just a body field thing - but I’ll be darned if I can see what I have wrong.

Doug

REM {Send email on the day before an item expires or on the day before the extension expiration date};

REM {Skip docs not created with the MSDS form. Skip items not expired. Skip hidden docs. Skip if chemical name is blank};

@If(

Form != “frmMSDSExpiration” ; @Return(“”);

Hide = “Hidden”;@Return(“”);

ChemicalName = “”; @Return(“”);

@Success);

SendTo := “Doug Finner”;

cc := “”;

bcc := “”;

Bdy := “”;

Subject := "TestWithDocLinks - MSDS Material: " + ChemicalName + " will expired on: " + @Text(ExpirationDate);

DbLink := “Notes://NotesKMC/” + @Subset(@DbName; -1) + “/vwExpiredMaterial”;

Remark := "Material: " + ChemicalName + " Lot Code: " + LotBatchCode + " in Location: " + Location + " will Expire effective tomorrow. Please note that the attached link may not work if the item’s status has changed since this email was sent. Make sure Notes is running and you are logged in, then follow this link: " + DbLink;

@If(

@Today < @Adjust(ExpirationDate; 0;0;3;0;0;0); @Return(“”);

@Today > @Adjust(ExpirationDate; 0;0;3;0;0;0); @Return(“”);

@Today = @Adjust(ExpirationDate; 0;0;3;0;0;0) & ExtendDate = “”; @MailSend( sendTo ; cc ; bcc ; Subject ; remark ; Bdy ; [IncludeDoclink]);

@Today = @Adjust(ExtendDate; 0;0;3;0;0;0) ; @MailSend( sendTo ; cc ; bcc ; Subject ; remark ; Bdy ; [IncludeDoclink]);

@Return(“”));

SELECT @All

Subject: Here’s some debug history

I took an existing db with no scheduled agents, added a simple agent that picks out one or two docs and sends and email on schedule with doc links. The ‘Body’ is computed with fields and static text. Email sent, doc links intact. (** code)

Compacted/Fixup on my problem db - no joy.

Made a fresh copy of my problem db (thinking any corruption might be cleaned up on copy) - no joy.

Modified the agent in the fresh copy to include one named field as the body and ‘Remark’ as the remark - no joy.

Removed doclink from MailSend in fresh copy, email sent.

Removed all but one condition from my date based @If statement and simplified the statement (thinking something in the If statement was mucked up) - no joy (* agent code below).

Trimmed Subject to ‘This is the Subject’ - no joy.

If I get more stuff that I’ve tried, I’ll add it here.

Doug

(*) Simplified Agent code - does not work if [IncludeDocLink] is part of the MailSend, works fine if [IncludeDocLink] is removed:

@If(

Form != “frmMSDSExpiration” ; @Return(“”);

Hide = “Hidden”;@Return(“”);

ChemicalName = “”; @Return(“”);

@Success);

SendTo := “Doug Finner”;

cc := “”;

bcc := “”;

Bdy := ChemicalName;

Remark := “Remark”;

Subject := "TestWithDocLinks - MSDS Material: " + ChemicalName + " will expired on: " + @Text(ExpirationDate);

@If(

@Today = @Adjust(ExpirationDate; 0;0;3;0;0;0); @MailSend( sendTo ; cc ; bcc ; Subject ; remark ; Bdy );

@Return(“”));

SELECT @All

(**) This works fine:

Bdy := "This doc was created: " + @Text(@Created) + " and is related to Section: " + SectionNumber + " and is based on stardard: " + StdSource;

@If(SectionNumber = “820.086”;

@MailSend(“Doug Finner”;“”;“”;“Subject”;“Remark”;Bdy;[IncludeDocLink]);

@Return(“”));

Subject: Holy crap!

If that’s true (Body reserved for field names only), I have a TON of code that’s working, has been working since R4x, and shouldn’t…meaning somewhere along the line, for some reason known only to my Domino server, it’s going to die and I’m going to have a buncha POd users…

I build text strings all the time and stuff them into the ‘Body’ part of the @mailsend for both real time and scheduled agents and it has NEVER not worked.

I do the same thing in LS - again, NEVER a problem…

Crap crap crap crap crrrrrraaaaaaap! I think the rest of my year just went to hell…

Why the hell would this stuff work forever and then suddenly in one app not work? Crap!

Thanks for the heads up. I’ll run some test code in my problem db and see what happens. I have no clue how I’m going to approach the rest of my apps.

Doug