Managing Resource Extended Attributes

The ExtendedAttribute property exposed by the Resource class can be used to manage the extended attributes of a resource. This property reads and writes an ArrayList of the ExtendedAttribute objects to deal with a resource’s extended attributes. The ExtendedAttribute object further exposes the relevant properties.

Setting Extended Resource Attributes with Aspose.Tasks

The following code example demonstrates how to set a resource’s extended attributes. This snippet shows how to create an extended attribute, assign it to a resource, and define custom values that extend the default properties.

 1Project project = new Project("New Project.mpp");
 2
 3// Define extended attribute
 4ExtendedAttributeDefinition myNumber1 = project.ExtendedAttributes.GetById((int)ExtendedAttributeTask.Number1);
 5if (myNumber1 == null)
 6{
 7    myNumber1 = ExtendedAttributeDefinition.CreateResourceDefinition(ExtendedAttributeResource.Number1, "Age");
 8    project.ExtendedAttributes.Add(myNumber1);
 9}
10
11// Create extended attribute and set its value
12ExtendedAttribute number1Resource = myNumber1.CreateExtendedAttribute();
13number1Resource.NumericValue = 30.5345m;
14
15// Add a new resource and its extended attribute   
16Resource resource = project.Resources.Add("R1");
17resource.ExtendedAttributes.Add(number1Resource);
18
19project.Save("ResourceExtendedAttributes_out.mpp", SaveFileFormat.MPP);

FAQ

Q: What are extended resource attributes in Microsoft Project?

Q: Can I define custom values for extended attributes programmatically?

Q: Do extended attributes remain available if I open the file in Microsoft Project?

Conclusion

Managing extended resource attributes with Aspose.Tasks for .NET gives you flexibility to add custom information to resources. By programmatically creating and assigning extended attributes, you can enrich project data and support advanced reporting or analysis without manual editing in Microsoft Project.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.