It's all about the answers!

Ask a question

Vacation workitem generating wrongly for 1 day when created thru code


Mohanraj Palanisamy (611) | asked Oct 16 '14, 8:30 a.m.
edited Oct 17 '14, 5:30 a.m. by Ralph Schoon (55.5k23642)
On Writing automation code to adding  absence workitem(  Scheduled absence workitem). If the code  has start date and end date as same, It is creating absence workitem for the previous date included.
For example: if i want to create workitem for Oct 22nd then the workitem created for 21-22 which is not right.
I have added the debug line for date before  passed it to the function  and it shows the proper value
Code snippet of schedule work item getting created.
----
IResourcePlanningClient resourcePlanningClient = (IResourcePlanningClient)iTeamRepo.getClientLibrary(IResourcePlanningClient.class);
        ContributorAbsence absence= (ContributorAbsence)IContributorAbsence.ITEM_TYPE.createItem();
        absence.setSummary(type.name());
        absence.setStartDate(startDate);   
        absence.setEndDate(endDate);
        absence.setContributor(engineer);
        // Debug statements of Date.
        System.out.println(absence.getStartDate()+"---"+absence.getEndDate());
        try {
            //
        resourcePlanningClient.saveAbsences(new ContributorAbsence[] { absence }, new NullProgressMonitor());
}
--
>> On the completion of code execution, We are able to see workitem for mentioned date and the previous one.
-----
Your help is much appreciated.

One answer



permanent link
Ralph Schoon (55.5k23642) | answered Oct 17 '14, 5:29 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see: https://rsjazz.wordpress.com/2014/07/22/manage-scheduled-absences-using-the-plainjava-client-libraries/

If the start date and the end date are the same you should have one day of absence.

Comments
Mohanraj Palanisamy commented Oct 17 '14, 5:51 a.m.

Thanks for the link Ralph.

Your answer


Register or to post your answer.