Adding to taskCollection creates resourceassignment

When I add new Task like:

Task task = taskCollection.add();
Then automatically I find an instance of ResourceAssignment in ResourceAssignmentCollection.
This instance is associated with the created Task but has no Resource.

There is no way, to delete this resource assignment or edit it.

Why is that?
How can I delete this ResourceAssignment from ResrouceAssignmentCollection?


Hi,


Thank you for writing to Aspose support team.

This behavior is implemented similar to Microsoft Project (MSP). Add two tasks in MSP and then save it as XML. Open this XML file in notepad, and observe that two resource assignments are added by default. Similarly you get resource assignments while using Aspose.Tasks. You may delete them by using ResourceAssignment.delete() function as shown in the following sample code. Please give it a try and let us know the feedback.

Project project = <span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:navy”>new
Project();
System.<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>out
.println(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“Before adding a
task to collection total resource assignments count =”
+ project.getResourceAssignments().getCount());

Task task1 = project.getRootTask().getChildren().add(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Task 1”
);

Task task2 = project.getRootTask().getChildren().add(
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:green”>“Task 2”
);

System.
<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>out
.println(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“After adding a
task to collection total resource assignments count =”
+ project.getResourceAssignments().getCount());

<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:navy”>while
(project.getResourceAssignments().getCount()>
<span style=“font-size:9.0pt;font-family:“Courier New”;mso-fareast-font-family:
“Times New Roman”;color:blue”>0)

{

ResourceAssignment asgn =
project.getResourceAssignments().toList().get(
<span style=“font-size:
9.0pt;font-family:“Courier New”;mso-fareast-font-family:“Times New Roman”;
color:blue”>0);

asgn.delete();

}

System.
<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:#660E7A”>out
.println(<span style=“font-size:9.0pt;font-family:“Courier New”;
mso-fareast-font-family:“Times New Roman”;color:green”>“After deleting all
, total resource assignments count =”
+ project.getResourceAssignments().getCount());