seegers
Returning Observer

Using API to create a MailTask

Hello,

I am trying to use the API to create and add a MailTask to an extisting ScheduleEntry.

The suitable method for this seems to be

 

createTask(Class<T> type)

 

 


 

My issue has been resolved, for future references:

import de.espirit.firstspirit.access.AdminService;
import de.espirit.firstspirit.access.Connection;
import de.espirit.firstspirit.access.admin.ProjectStorage;
import de.espirit.firstspirit.access.schedule.MailTask;
import de.espirit.firstspirit.access.schedule.ScheduleEntry;
import de.espirit.firstspirit.access.schedule.ScheduleStorage;
import de.espirit.firstspirit.access.schedule.ScheduleTask;

Connection conn=context.getConnection();
AdminService as=conn.getService(AdminService.class);
ProjectStorage ps=as.getProjectStorage();
ScheduleStorage ss=as.getScheduleStorage();


for(prj:ps.getProjects(true)){}
    ScheduleEntry se=ss.getScheduleEntry(prj,"ScheduleEntry Name");
    if(null!=se){
        ScheduleTask newTask=se.createTask(MailTask.class);
        /* modify newTask here
        
         */
        prj.lock();
        se.lock();
        se.getTasks().add(newTask)
        se.save();
        se.unlock();
        prj.save();
        prj.unlock();
    }
}
0 Kudos
0 Replies