Parker Software Ltd Homepage
Forum Home Forum Home > Email2DB Email Parser > Scripting > Scripting Samples
  New Posts New Posts RSS Feed: Cancelling a trigger using an extraction script
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Cancelling a trigger using an extraction script - Event Date: 01 Nov 2005 - 19 Jul 2006

 Post Reply Post Reply
Author
Message
Stephen View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 Oct 2005
Location: Stoke on Trent
Posts: 1389
Post Options Post Options   Quote Stephen Quote  Post ReplyReply Direct Link To This Post Calendar Event: Cancelling a trigger using an extraction script
    Posted: 01 Nov 2005 at 11:29am
You can use extraction scripts to cancel trigger execution based on specific criteria.

For example, the script below was added to an extracted field:

Sub Main
If MSG_From = "me@myemail.com" Then Email2DBTrigger = False
End Sub


Will cancel the trigger if the built in field 'From address' is "me@myemail.com". This incoming email will then not be processed by this trigger.

Another example:

Sub Main
If FIELDS_Value("customer") <> "ACE Clothing" Then Email2DBTrigger = False
End Sub


Will cancel the trigger if the extracted field "customer" does not equal "ACE Clothing"
 
Another example:

Sub Main
If FIELDS_Value("email") LIKE "*@mysite.com" Then Email2DBTrigger = True Else Email2DBTrigger = False
End Sub
Use the LIKE operator to compare against a string with wildcards - as in the above example, the trigger will only be fired if the Field value 'email' is from any email address ending with 'mysite.com'.
 
Basically - setting the Email2DBTrigger = False in any extraction script will cancel the trigger. You can also set it in the Action script.


Edited by Stephen - 29 Jul 2009 at 6:01pm
Back to Top
MSevast View Drop Down
New User
New User


Joined: 20 Jun 2006
Location: Cincinnati, OH
Posts: 19
Post Options Post Options   Quote MSevast Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2006 at 2:51am
Is it possible to cancel a trigger when a lookup field fails because of a SQL Server deadlock?
Back to Top
MSevast View Drop Down
New User
New User


Joined: 20 Jun 2006
Location: Cincinnati, OH
Posts: 19
Post Options Post Options   Quote MSevast Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2006 at 3:01am
Here is the error I am receiving. I have added the NOLOCK tip but it does seem to help when the database is being updated during our monthly batch updates. I can't stop the Email2DB service during these updates as I have other triggers that are not dependent on the database and I want to make as much up time as possible. 2006-07-07:15:43:50 *Error lookup field:Timeout expired 2006-07-07:15:43:50 *SQL Was: SELECT TOP 1 UserID FROM PanTable NOLOCK WHERE email = 'myemail@hotmail.com' Thanks, Michael
Back to Top
Stephen View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 Oct 2005
Location: Stoke on Trent
Posts: 1389
Post Options Post Options   Quote Stephen Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2006 at 10:34am
Hi, I will add a 'Cancel Trigger If Lookup Fails' option to the lookup field. Expect this in the next update (later this week). Thanks Steve
Back to Top
MSevast View Drop Down
New User
New User


Joined: 20 Jun 2006
Location: Cincinnati, OH
Posts: 19
Post Options Post Options   Quote MSevast Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jul 2006 at 3:07pm
Thank you very, very much for all the rapid attention to the issues!!!!
Back to Top
MSevast View Drop Down
New User
New User


Joined: 20 Jun 2006
Location: Cincinnati, OH
Posts: 19
Post Options Post Options   Quote MSevast Quote  Post ReplyReply Direct Link To This Post Posted: 14 Jul 2006 at 5:10pm
Steve, Have you had any success incorporating this change into a new build? If the trigger is cancelled, and I have delete Processed and Delete All Checked emails, will this prevent the message from being deleted? I need to make sure I don't purge these records so that I have a shot at getting them into the DB once the issue that is causing the deadlock resolves itself. Michael
Back to Top
Stephen View Drop Down
Admin Group
Admin Group
Avatar

Joined: 21 Oct 2005
Location: Stoke on Trent
Posts: 1389
Post Options Post Options   Quote Stephen Quote  Post ReplyReply Direct Link To This Post Posted: 18 Jul 2006 at 2:02pm
Hi, The build is now posted. Select Help - Check For Updates to download it. Thanks Steve
Back to Top
MSevast View Drop Down
New User
New User


Joined: 20 Jun 2006
Location: Cincinnati, OH
Posts: 19
Post Options Post Options   Quote MSevast Quote  Post ReplyReply Direct Link To This Post Posted: 19 Jul 2006 at 5:04pm
Until the Help file is updated, can you give me a quick rundown of what is cancelled when the 'Cancel Trigger If Lookup Fails' happens. I need to make sure the message is not deleted so it can be reprocessed at another time. The delete message setting is at the account level so I am worried a trigger failure will not stop the message from being deleted. Thanks, Michael
Back to Top
Liam View Drop Down
Admin Group
Admin Group
Avatar

Joined: 29 Jun 2011
Location: Stoke-on-Trent
Posts: 137
Post Options Post Options   Quote Liam Quote  Post ReplyReply Direct Link To This Post Posted: 29 Sep 2011 at 7:34pm
Here is a script that will compare the first two characters of an extracted field with another value, if the two values match then the message will continue to process as normal, if they don't then processing of that message will be cancelled.
 
Here is a link to a description of the Mid function - http://www.w3schools.com/vbscript/func_mid.asp
The first number dictates where the new string is to begin, 1 is the first character, the second number tells Email2Db how many characters to extract after the starting point.
 
Sub Main()

 

   Dim extract As String

   Dim comp As String   comp = "{string}" 'The string that will be compared   
   'Convert the extracted data to upper case (means that different cases will be matched the same)
   'and then get the first two characters of the extracted string

   extract = UCase(Mid(Email2DBExtract, 1, 2))

 

   'Compare the first 2 letters of the extraction to the string RA
   If
StrComp(extract, comp) = 0 Then
      Email2DBTrigger = True
'Trigger continues to process
   Else
      Email2DBTrigger = False
'Cancels the running of the trigger
   End If

 

End Sub



Edited by Liam - 30 Sep 2011 at 1:34pm
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down



This page was generated in 0.297 seconds.
These are the forums for Parker Software, developers of Live Chat Software: WhosOn and Email Automation Software: Email2DB.