Retrieve a Task's Budget Work and Cost Values

Microsoft Project 2007 and 2010 provide budget cost and budget work as task fields. Aspose.Tasks for Java provides these properties as Task.BudgetWork and Task.BudgetCost.

Reading Budget Work and Cost Value

The following lines of code retrieve a task’s budget work and cost information.

 1// For complete examples and data files, please go to https://github.com/aspose-tasks/Aspose.Tasks-for-Java
 2// The path to the documents directory.
 3String dataDir = Utils.getDataDir(TaskBudgetWorkAndCost.class);
 4
 5Project project = new Project(dataDir + "input.mpp");
 6Task projSummary = project.getRootTask();
 7
 8System.out.println("projSummary.BudgetWork = " + projSummary.get(Tsk.BUDGET_WORK));
 9System.out.println("projSummary.BudgetCost = " + projSummary.get(Tsk.BUDGET_COST));
10
11// Get resource by Uid
12Resource rsc = project.getResources().getByUid(1);
13
14// Display resource budget work
15System.out.println("Resource BudgetWork = " + rsc.get(Rsc.BUDGET_WORK));
16
17// Get next resource by Uid
18rsc = project.getResources().getByUid(2);
19
20// Display resource budget cost
21System.out.println("Resource BudgetCost = " + rsc.get(Rsc.BUDGET_COST));
22
23for (ResourceAssignment assn : projSummary.getAssignments()) {
24    if (assn.get(Asn.RESOURCE).get(Rsc.TYPE) == ResourceType.Work)
25        System.out.println("Assignment BudgetWork = " + assn.get(Asn.BUDGET_WORK));
26    else
27        System.out.println("Assignment BudgetCost = " + assn.get(Asn.BUDGET_COST));
28}
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.