Knowledgebase & FAQ
How do I e-mail enable K1?
Email enabling K1 is quite straight forward.
Already in K1 is a scheduled task which automatically sends out e-mails waiting in a queue every minute. To email enable any function within K1 all you have to do is place an e-mail on the queue.
Where’s the Email Queue?
The e-mail queue is a table called EmailNotification. It consists of three fields, they are:
- RecipientID – The internal ID of the intended email recipient from the Person record (Note: K1 sends the e-mail to the WorkEmail address specified for the person)
- Subject – The subject of the email (limited to 200 characters)
- BodyText – The body of the email (limited to 2000 characters)
How to put an e-mail in to the queue?
To add processing logic to K1 you use triggers. Triggers are instructions which automatically occur when you either add, modify and/or delete a record from a table.
Using the DRM any table can have a trigger applied to insert the necessary information in to the EmailNotification table.
There are a number of different events that can cause a trigger to occur. For the purpose of this example we will add a simple trigger that occurs when a record is added to the K1 EDOC table.
Our trigger will send an email to the “Delegate” specified on the EDOC record. The Delegate field is a link to a Person record where the Scheduled Task will find the person’s e-mail address. Depending on the table you are adding the trigger to, you will need to use a different field or if you want e-mails to go to the same person each time, hard-code in an internal ID.
All triggers in K1 must be added using the DRM. Using the DRM, we would go to the Triggers screen and select Add.
We need to add an External ID, a security code, a database name and select the table which the trigger will use. We also need to define the action and when the trigger is to occur. See below for our settings.
These settings mean that the triggers runs AFTER a record is INSERTED.
The SQL query will be as follows:
DECLARE @PersonID INT, @Subject
NVARCHAR(100), @BodyText NVARCHAR(500), @EDOCID NVARCHAR(15), @EmailAddr
SELECT @PersonID = [DelegatePersonID], @EDOCID =[ExternalID] FROM Inserted
SELECT @EmailAddr = [WorkEmail] FROM Person WHERE [ID] = (SELECT [DelegatePersonID] FROM Inserted)
IF @PersonID IS NOT NULL AND @EmailAddr IS NOT NULL
SELECT @Subject = 'A K1 EDOC has been added that requires your attention'
SELECT @BodyText = 'EDOC ref#' + @EDOCID + ' has been added to K1 and requires your attention'
INSERT INTO EmailNotification (RecipientID, Subject, BodyText) VALUES (@PersonID, @Subject ,@BodyText)
So what is this query doing?
- first it declares the variables we will be using through-out the query including their type and length
- it then gets the EDOC External ID and the delegate ID from the EDOC record we’ve just added
- it then gets the work e-mail address of the delegate from the PERSON table
it then checks to make sure that a delegate was specified and it has an e-mail address
if a delegate was specified, it sets the subject variable to be ‘A K1 EDOC has been added that requires your attention’ and sets the body text to be ‘EDOC ref#<external ID of the EDOC>
has been added to K1 and requires your attention'
It then adds the e-mail to queue (ie. EmailNotification table)
You can obviously change the subject and body to be anything you wish. If you wanted to include other fields from within the database you just need to make sure you declare the variables and SELECT the required data in to those variables prior to including them in the subject or body. (Don’t forget that the subject must be less than 200 characters and the body 2,000 characters)
This is an example of the e-mail that we’ve configured:
If you need assistance creating a trigger, please contact your account manager or Knowledgeone Corporation Support for a quotation.
Don’t forget to check your Scheduled Task!
Should you find K1 not sending out emails in your queue, check that the EmailAnnouncement_Insert scheduled task is correctly configured for your environment.
This is done by going through the DRM and proceeding to the list of Scheduled Tasks. Modify the EmailAnnouncement_Insert scheduled task and ensure that there is:
- a “sender’s e-mail” specified
- a “SMTP server” (ie. the name/address of e-mail server)
- the task is marked as active
See below for an example: