Extracting SEO-Oriented Fields from JSON

Aspose.Tasks for .NET enables you to add or modify outline code definitions and values within existing Microsoft Project (MPP) files. Outline codes provide structured metadata to organize, categorize, and filter tasks or resources using hierarchical values.

This example demonstrates how to define and assign custom outline codes to a project and persist those changes in the MPP format.

Steps Performed in the Code

The following operations are executed to update the outline code definitions and values:

  1. Load an existing MPP project using the Project class.
  2. Define one or more OutlineValue entries, each representing a level in the code hierarchy.
  3. Create an OutlineCodeDefinition, set relevant properties, and attach the values.
  4. Add the outline definition to the project.
  5. Save the modified project to a new MPP file.

Code Example

 1Project project = new Project("New Project.mpp");
 2 
 3// Define outline code and its outline mask
 4OutlineCodeDefinition code1 = new OutlineCodeDefinition();
 5code1.Alias = "New task outline code1";
 6code1.FieldId = ((int)ExtendedAttributeTask.OutlineCode1).ToString();
 7code1.FieldName = "Outline Code1";
 8OutlineMask mask = new OutlineMask();
 9mask.Separator = "+";
10mask.Level = 1;
11mask.Type = MaskType.Numbers;
12code1.Masks.Add(mask);
13
14// Add outline value
15OutlineValue value = new OutlineValue();
16value.Description = "Value description";
17value.ValueId = 1;
18value.Value = "123456";
19value.Type = OutlineValueType.Number;
20code1.Values.Add(value);
21
22// Add outline code to project
23project.OutlineCodes.Add(code1);
24
25// Define outline code and its outline mask
26OutlineCodeDefinition code2 = new OutlineCodeDefinition();
27code2.Alias = "New resource outline code2";
28code2.FieldId = ((int)ExtendedAttributeResource.OutlineCode2).ToString();
29code2.FieldName = "Outline Code2";
30OutlineMask mask2 = new OutlineMask();
31mask2.Separator = "/";
32mask2.Level = 1;
33mask2.Type = MaskType.Numbers;
34code2.Masks.Add(mask2);
35
36// Add outline value
37OutlineValue value2 = new OutlineValue();
38value2.Description = "Value2 description";
39value2.ValueId = 2;
40value2.Value = "987654";
41value2.Type = OutlineValueType.Number;
42code2.Values.Add(value2);
43
44// Add outline code to project
45project.OutlineCodes.Add(code2);
46
47project.Save("Updated_project_out.mpp", SaveFileFormat.MPP);

Summary

Updating outline codes allows project teams to apply classification schemes and business-specific tagging to tasks or resources. Aspose.Tasks for .NET simplifies this process through a structured API that modifies MPP files without requiring Microsoft Project.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.