It's all about the answers!

Ask a question

Send a custom email on evenement


Mathieu Defianas (15952938) | asked Oct 24 '13, 11:45 a.m.
Hello,
I use RTC.4.0.3 and I have created a custom email template. No problem, my custom emails are sent to owner or creator when the workitem state is changed.

First problem : when I create a workitem without assigning a owner, no email is sent whereas I would like that a email is sent to the creator
Next problem : I would like to notify some people when a workitem is created without adding all people on subscribers.

I have found this link (https://jazz.net/jazz/web/projects/Jazz%20Collaborative%20ALM#action=com.ibm.team.workitem.viewWorkItem&id=216962%C2%A0) and so I think that my problems are not supported by RTC.
But I think that I can resolve my problem with JAVA API and send an email when I clic on "save".

OK, so I have tried to load my email custom template (saved in my project) with a java code on the event "com.ibm.team.workitem.operation.workItemSave". I have tried it :
IProjectAreaHandle iProjectAreaHandle = newWorkItem.getProjectArea() ;
IProjectArea iProjectArea = (IProjectArea) auditableCommon.resolveAuditable(iProjectAreaHandle, ItemProfile.createFullProfile(IProjectArea.ITEM_TYPE), monitor) ;
Map<String, IContent> map = iProjectArea.getProcessData();
Collection<IContent> list = map.values() ;
IProcessDefinitionHandle iProcessDefinitionHandle = iProjectArea.getProcessDefinition() ;
IProcessDefinition iProcessDefinition = (IProcessDefinition) auditableCommon.resolveAuditable(iProcessDefinitionHandle, ItemProfile.createFullProfile(IProcessDefinition.ITEM_TYPE), monitor) ;
Map<String, IContent> map2 = iProcessDefinition.getProcessData() ;
Collection<IContent> list2 = map2.values() ;
The email template is not included on my list or list2 ...
Have you got an idea to load this email template ?
Then, have you got an idea to send an email with JAVA API ? Are there mail library already included on the SDK ?
Thanks for your help.

Regards
Mathieu

One answer



permanent link
Aradhya K (1.4k54345) | answered Oct 25 '13, 5:41 a.m.
JAZZ DEVELOPER
 IProcessArea processArea= (IProcessArea)getService(IRepositoryItemService.class).fetchItem(projectArea, IRepositoryItemService.COMPLETE);
IServerProcess serverProcess= getService(IProcessServerService.class).getServerProcess(processArea);
IProcessConfigurationData data= serverProcess.getProjectConfigurationData("com.ibm.team.workitem.configuration.emailTemplates");

Above lines of code will get you the templates, but is there a reason why you are trying to read the templates??

Comments
Mathieu Defianas commented Oct 25 '13, 9:22 a.m.

Hello Aradhya
I am going to test your solution but I must adapt it because my code is executed on server side.
I would like to read the template in order to send an email using it when I change a specific state of a Workitem

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.