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

Free Support Forum - aspose.com

Mpp file get task and update taskname, resource name, start finish time - Java

Hi Aspose Team,

My requirements are filter tasks by name or time intervals and update task name, resource, start, finish time. I’ve tried by id and applied if condition for time intervals.

  1. Do you have any search methods which will return the list of tasks search by specific time intervals.

For update task name, resource, start, finish time I could not able to do due to evolution mode.
2. Could you please let me now, before purchase how can I make sure that those functionality would work properly. Even I did not find your documentation to update those.

I’ve gone through the documentation (https://purchase.aspose.com/temporary-license) for temporary license. Any other alternative before quote.

Thanks,
Rupam

@ibinpvt,

You can iterate over project’s tasks and apply any condition you like:


            foreach (var task in project.EnumerateAllChildTasks())
            {
                if (task.Start > new DateTime(2022, 1, 1)) // sample condition
                {
                    // Update task fields here
                }
            }

            // Save updated project to file
            project.Save("output.mpp");

The documentation for Aspose.Tasks can be found here

Do you mean that when you try to save the project, “The operation is not allowed in evaluation mode.” exception is thrown ?

The only way is to request a temporary license, apply it and and try your scenario using it.

I am looking for Java solution. The java documentation I searched, all are create new task (https://docs.aspose.com/tasks/java/). Could you please tell me how to update task properties as I mentioned.

Answer to your query :
Do you mean that when you try to save the project, “The operation is not allowed in evaluation mode.” exception is thrown ?
Yes. Getting exception . “Exception in thread “main” java.lang.UnsupportedOperationException: The operation is not allowed in evaluation mode.”

The main idea is the same: iterate over all project’s tasks, and modify the task if it
satisfies the conditions:


        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-d HH:mm");
        Date testDate = sdf.parse("2022-1-4 9:30");


        for (Task t : project.enumerateAllChildTasks())
        {
            if (t.get(Tsk.START).before(testDate)) // Sample condition
            {
                // Update task as per your requirements
                t.set(Tsk.START, testDate);
                t.set(Tsk.Name, "Updated name");
            }
        }

        project.save("output.mpp");

Your haven’t set the license. You should get temporary license and apply it in your code. Please refer to Applying License section.