We have implemented a Questions System where anyone can ask a question by posting an operation to a task.
- The user create the Question set the operation assignee to the person they want to ask
- The person who is asked is sent an e-mail notification
- The person who is asked is set as "Informat", which is a task UDF field
- Importantly the task assignee is not changed
Implementation in TS 3
A before add message script does as follows
- Sets message.udf.informant = message.assignee
- Sets message.assignee = task.assignee
Behaviour in TS 4
The email notificartion gets sent to task.assignee (who is usually the person asking the question!), not message.assignee
First attempt at fix
Before add message script
- Sets message.udf.informant = task.assignee
After add message script
- Sets task.assignee = message.udf.informant (puts task.assignee back to original value)
- Sets message.udf.informant = message.assignee
- Code: Select all
AdapterManager.getInstance().getSecuredTaskAdapterManager().updateTask(message.getSecure(), task.getId(), task.getShortname(), task.getName(), task.getDescription(), task.getBudget(), task.getDeadline(), task.getPriorityId(), task.getParentId(),
assignee, null, false);
produces error: "com.trackstudio.exception.GranException: Could not execute JDBC batch update"
If the handlerUserId paremeter is set to null there is no error, but also there is not point in calling the method.
Second attempt at fix
Create the e-mail in before add message script.
From searching the forum I gather than JavaMail has to be used.
JavaMail cannot use templates
![Sad :(](http://www.trackstudio.ru/forum/images/smilies/icon_sad.gif)
But
- How do we access and use JavaMail?
- How do I access the Config object in order to getSiteURL() to provide a link to the task in the e-mail?
Would you please suggest a better solution, identify where I am going wrong in the first attempt or, as last resort, give an example of creating an e-mail in a trigger. Many thanks in advance.
Simon