I have an agent with the following code:
SendTo := Assignees;
@If(pctComplete = “100”;@SetField(“reqStatus”;“Complete”) ;
reqStatus = "Complete";@SetField("pctComplete";"100") ;"");
@If(pctComplete = “100” | reqStatus = “Complete”;
@MailSend(SendTo;“”;" “;”!!! IMPORTANT - Task Assignment Complete.“;”";"The attached assigned task has been completed: " + @NewLine + @NewLine +"Please click on the enclosed doclink to review the completed assignment.—> ";[IncludeDoclink]);
@MailSend(SendTo;“”;“”;“!!! IMPORTANT - Task Assignment.”;“”;“The attached task has been assigned to you for completion: " + @NewLine + @Name([CN];Requestor) + " is requesting the assigned task to be completed by " + @Text(reqDueDate)+”." + @NewLine + @NewLine +"Please click on the enclosed doclink to review the assigned task.—> ";[IncludeDoclink]))
I’m receiving duplicate messages when either mail message is sent. I’ve tried removing the code to see if the message is being sent from elsewhere in the database but then it doesn’t send at all. Any ideas why this is duplicating?
Thanks,
Subject: Agent sends duplicate mail message
How are you running the agent?
Craig.
Subject: RE: Agent sends duplicate mail message
Its being kicked off in the QuerySave.
Subject: RE: Agent sends duplicate mail message
Hrm, does it ask twice if you want to save the document when you save it? I can well imagine that changing fields in query save would do that.
The first thing I would try would be to put the formula which changes the field values into the respective field InputTranslation sections, and then just run the “emailing” part in your agent which runs on QuerySave.
For example, in your reqStatus field, make the InputTranslation :
@If( pctComplete = “100”; “Complete”; @ThisValue )
Is that doable?
C.
Subject: RE: Agent sends duplicate mail message
Well, your idea was a good one but no luck. I’ve taken out the setting of the fields and left only the @mailsend and it still sends two messages rather than one.
Any other ideas?
Subject: RE: Agent sends duplicate mail message
How are you saving the documents? Do you click a Save or a Save & Close button, or are you hitting Escape and choosing Yes to save changes?
If you are using a button, does the button set any other fields when you click it?
If you just do a Ctrl+S, does it send one or two?
C.
Subject: RE: Agent sends duplicate mail message
Make sure you don’t have the agent trigger set to some schedule trigger. I have seen customers who had the agents invoked via save as well as have it run scheduled, and so it would be doing the work twice.
Subject: RE: Agent sends duplicate mail message
Thanks, Craig! Actually I’d missed the fact that originally I had called the agent with the save button. I was calling it twice.
Subject: RE: Agent sends duplicate mail message
Doh! LOL.
Glad it’s sorted & glad to help.
C.