Extended Attributes (Duration) missing not retained on new MPP file

Hi,

I’ve used sample code provided, in a previous post response from Aspose, and it’s adding extended attributes as expected. However, when I read the newly created file and check the attribute count on the task it’s only showing 2 when it should be 3 (Missing the duration attribute). If I change the duration attribute and add a cost attribute (e.g. Cost10) I then get three attributes for each task in the project (excluding the root). Any ideas on how to add the duration attribute and keep it around on a read of the newly created MS project file?

Create the MPP file from a template (Template is attached):

Project _project = new Project("New Project 2010.mpp");
OutlineCodeDefinition textOutline = new OutlineCodeDefinition();
project.OutlineCodes.Add(textOutline);
// add a mask for text field
OutlineMask mask = new OutlineMask();
mask.Type = MaskType.Characters;
textOutline.Masks.Add(mask);
OutlineValue textValue = new OutlineValue();
textValue.Value = "Text value1";
textValue.ValueId = 1;
textValue.Type = OutlineValueType.Text;
textValue.Description = "Text value descr";
textValue.FieldGuid = Guid.NewGuid().ToString().ToUpper();
textOutline.Values.Add(textValue);
OutlineCodeDefinition costOutline = new OutlineCodeDefinition();
project.OutlineCodes.Add(costOutline);
// add a mask for cost field
OutlineMask mask2 = new OutlineMask();
mask2.Type = MaskType.Val4;
costOutline.Masks.Add(mask);
OutlineValue costValue1 = new OutlineValue();
costValue1.Type = OutlineValueType.Cost;
costValue1.Value = "99900";
costValue1.ValueId = 2;
costValue1.Description = "Cost value 1 descr";
costValue1.FieldGuid = Guid.NewGuid().ToString().ToUpper();
costOutline.Values.Add(costValue1);
OutlineValue costValue2 = new OutlineValue();
costValue2.Type = OutlineValueType.Cost;
costValue2.Value = "11100";
costValue2.ValueId = 3;
costValue2.Description = "Cost value 2 descr";
costValue2.FieldGuid = Guid.NewGuid().ToString().ToUpper();
costOutline.Values.Add(costValue2);
// Add new cost1 extended attribute and text3 extended attribute
ExtendedAttributeDefinition taskTextAttr = new ExtendedAttributeDefinition();
taskTextAttr.Alias = "New text3 attribute";
taskTextAttr.FieldId = ExtendedAttributeTask.Text3.ToString("D");
// add a reference to lookup table
taskTextAttr.LookupUid = textOutline.Guid;
taskTextAttr.CfType = CustomFieldType.Text;
project.ExtendedAttributes.Add(taskTextAttr);
ExtendedAttributeDefinition taskCostAttr = new ExtendedAttributeDefinition();
taskCostAttr.Alias = "New cost1 attribute";
taskCostAttr.CfType = CustomFieldType.Cost;
taskCostAttr.FieldId = ExtendedAttributeTask.Cost1.ToString("D");
// add a reference to lookup table
taskCostAttr.LookupUid = costOutline.Guid;
project.ExtendedAttributes.Add(taskCostAttr);
//New Duration
ExtendedAttributeDefinition myTaskDurattr = new ExtendedAttributeDefinition();
myTaskDurattr.Alias = "New Duration";
myTaskDurattr.CfType = CustomFieldType.Duration;
myTaskDurattr.FieldId = ExtendedAttributeTask.Duration10.ToString("D");
project.ExtendedAttributes.Add(myTaskDurattr);
// Add new task and assign attribute value
Task task = project.RootTask.Children.Add("New task");
ExtendedAttribute taskAttr = taskCostAttr.CreateExtendedAttribute();
// add a reference to lookup table value
taskAttr.ValueGuid = costValue1.FieldGuid;
task.ExtendedAttributes.Add(taskAttr);
ExtendedAttribute taskAttrText = taskTextAttr.CreateExtendedAttribute();
// add a reference to lookup table value
taskAttrText.ValueGuid = textValue.FieldGuid;
task.ExtendedAttributes.Add(taskAttrText);
//Duration
ExtendedAttribute taskAttrDur = myTaskDurattr.CreateExtendedAttribute();
task.ExtendedAttributes.Add(taskAttrDur);
MPPSaveOptions mppSaveOptions = new MPPSaveOptions();
mppSaveOptions.WriteViewData = true;
//Save the project as MPP project file
project.Save("result.mpp", mppSaveOptions);
Read the result file and check the extended attributes (The newly added task will only have an extended attribute count of 2):
Project _project = new Project("result.mpp");
// Parse through all the collected tasks
foreach (Task myTask in collector.Tasks)
{
    // Just adding a break point below and preforming a watch on the myTask object to get the count.
}

I’ve downloaded a trial version of 9.2.1 of which I have a temporary license for evaluation. I’m using VS 2010 and MS Project 2010.

Thanks, Calvin

Hi Calvin,


Thank you for contacting Aspose support team.

This issue is re-produced and logged under Id: TASKS-34490 for further investigation by the product team. You will be automatically notified, once any update is received in this regard.

Hi Kashif,


Are you able to tell me if TASK - 34490 will be addressed in the upcoming release (9.3.0)?

Thanks, Calvin

Hi Kashif,


All extended attributes are now being picked up on subsequent reads of the generated MSP file.

Thanks for your help on this one.

Regards, Calvin

Hi Calvin,


Thank you for the feedback.