We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Not able to save ActualFinish Date

We are using a temporary license to evaluate reading and saving the MPP files from a java program using aspose-tasks-22.2-jdk18.jar

We have an MPP file where some tasks do not have the actual finish dates and hence are appearing as NA in Microsoft Project. We are updating these tasks’ actual dates with the values computed via a business logic in our Java program.

When we update the actual date, the object is showing proper value in the debugger after the set API. When this file is saved as an MPP file, the Actual date is not getting updated and it continues to be displayed as NA in Project.

If the Actual date is present in a task and we update it, the update and save works fine.

The API we are using is
Task p_oTask ; // Some valid task is assigned here
Date oDate = Calendar.getInstance().getTime();
oTask.set(Tsk.ACTUAL_FINISH, oDate);

Why are we facing this problem?

@Louis.Coutinho,

I’ve tried to reproduce the issue using version 22.2 and the following code:

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Project p = new Project();
Task t = p.getRootTask().getChildren().add("New task");
t.set(Tsk.START, dateFormat.parse("2022-04-11 09:00:00"));
t.set(Tsk.DURATION, p.getDuration(5));
t.set(Tsk.ACTUAL_FINISH, dateFormat.parse("2022-04-19 17:00:00"));
p.save("output.mpp");

and opened the resulting file using Microsoft Project. The value of Actual Finish is shown properly.

Could you provide a source code example which can be used to reproduce the issue?

I was not setting the duration. Once I did that the code is working fine.

I have a follow-up question. I cannot set the duration for Finish date because we get the Finish date from our system based on some business logic. When I try to set the duration (which is difference between two dates as days elapsed), Aspose Task is taking this as Business days and therefore the Finish date computation is wrong. I cannot match the Business days calculation in our module to mimic the Calendar set in the MPP file.

Is there any way to update the Finish date without specifying the duration and have the duration computed in the MPP based on Start and Finish dates?

@Louis.Coutinho

you could use Automatic project calculation mode and
set task’s Start and Finish dates . Duration should be calculated automatically in this case (as in Microsoft Project).