Working with Outline Codes in a Project

Outline codes in Microsoft Project are custom tags that allow you to define an alternative project structure, different from WBS codes or outline numbers. They are especially useful when you need to categorize tasks or resources according to organizational or enterprise standards. With Aspose.Tasks for .NET, you can retrieve, analyze, and manage outline codes and their properties, such as Alias, AllLevelsRequired, Enterprise, EnterpriseOutlineCodeAlias, FieldId, FieldName, PhoneticAlias, Guid, Masks, and Values.

Reading Outline Codes

The Project class exposes the OutlineCodes collection, which contains OutlineCodeDefinition objects.
These definitions provide detailed information about each outline code.

The following example demonstrates how to read outline code information from a project:

 1Project project = new Project("New Project.mpp");
 2
 3foreach (OutlineCodeDefinition ocd in project.OutlineCodes)
 4{
 5    Console.WriteLine("Alias = " + ocd.Alias);
 6    if (ocd.AllLevelsRequired)
 7        Console.WriteLine("It contains property: must have all levels");
 8    else
 9        Console.WriteLine("It does not contain property: must have all levels");
10    if (ocd.Enterprise)
11        Console.WriteLine("It is an enterprise custom outline code.");
12    else
13        Console.WriteLine("It is not an enterprise custom outline code.");
14
15    Console.WriteLine("Reference to another custom field for which this outline code definition is an alias is = " + ocd.EnterpriseOutlineCodeAlias);
16    Console.WriteLine("Field Id = " + ocd.FieldId);
17    Console.WriteLine("Field Name = " + ocd.FieldName);
18    Console.WriteLine("Phonetic Alias = " + ocd.PhoneticAlias);
19    Console.WriteLine("Guid = " + ocd.Guid);
20
21    // Display outline code masks
22    foreach (OutlineMask outlineMask in ocd.Masks)
23    {
24        Console.WriteLine("Level of a mask = " + outlineMask.Level);
25        Console.WriteLine("Mask = " + outlineMask.ToString());
26    }
27
28    // Display out line code values
29    foreach (OutlineValue outlineMask1 in ocd.Values)
30    {
31        Console.WriteLine("Description of outline value = " + outlineMask1.Description);
32        Console.WriteLine("Value Id = " + outlineMask1.ValueId);
33        Console.WriteLine("Value = " + outlineMask1.Value);
34        Console.WriteLine("Type = " + outlineMask1.Type);
35    }
36}

Check Outline Code Id Uniqueness

When working with outline codes, Aspose.Tasks for .NET automatically checks the uniqueness of Outline Code IDs. If duplicate IDs are found, they are replaced with unique values to maintain data integrity.

 1Project project = new Project("New Project.mpp");
 2
 3OutlineCodeDefinition textOutline = new OutlineCodeDefinition();
 4textOutline.FieldId = ExtendedAttributeTask.OutlineCode7.ToString("D");
 5textOutline.Alias = "My Outline Code";
 6
 7project.OutlineCodes.Add(textOutline);
 8
 9OutlineMask mask = new OutlineMask();
10mask.Type = MaskType.Characters;
11textOutline.Masks.Add(mask);
12
13OutlineValue textValue = new OutlineValue();
14textValue.Value = "Text value 1";
15textValue.ValueId = 1;
16textValue.Type = OutlineValueType.Text;
17textValue.Description = "Text value descr 1";
18textOutline.Values.Add(textValue);
19
20project.Save("MultipleOutlineValues.mpp", SaveFileFormat.MPP);

Outline codes provide a powerful way to add custom categorization and structure to your Microsoft Project data.
By using Aspose.Tasks for .NET, you can programmatically access and manage these codes, ensuring consistency and eliminating errors such as duplicate identifiers.
This makes it easier to enforce enterprise-wide standards and improve project reporting and analysis.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.