We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ExtendedAttributes attribute populated when plan is empty

Hi


When I import the attached plan the ExtendedAttributes attribute on the project object contains 410 elements.

When I open the plan the custom columns are empty.

Can you please have a look at the plan to see why this could be happening?

TIA

Craig

Hi Craig,


Thanks for writing to Aspose.Tasks support team.

I have analyzed the sample MPP file and found that all the extended attributes are not empty like “Number2” and “Flag2”. The values can be seen in the attached snapshot. Please provide us the details about the extended attributes whose values are available but not visible in MSP or not read by Aspose.Tasks.

Also, could you please confirm if this MPP file is created using Aspose.Tasks? If so, could you please provide the sample code to create this MPP file? It will help us to assist you further.

Hi Kashif

You are right about those extended attributes but there are many appearing in the collection that are empty in the plan.

For example, OutlineCode10 - it has no values in the plan yet element 129 of the collection contains OutlineCode10

When I analyse other MS Project plan with a blank OutlineCode10 it never appears in the collection - whereas for this plan it does.

I am using ASPOSE tasks to read MS Project plans to import the data in the plans into my database.

HTH


Craig

Hi Craig,


Thanks for writing again.

I have tested the scenario again and need little clarification. There are 410 extended attribute definitions in the project object. This project contains 85 tasks where only three extended attributes Number2, Flag1 and Flag2 contain values for different tasks. Rest of the 407 extended attributes including OutlineCode10 do not have any value assignment for any of the task. Could you please elaborate it that which element 129 in the collection contain values as I am unable to identify the problematic element? It is also observed that project extended attribute definition element 129 contains empty ValueList.

Please send us the sample code which can be used to re-produce the issue here along with the snapshots (if any). Thanks in advance for your cooperation.

I have used following code for testing:

static public void DisplayProjectExtendedAttributes()
{
Project prj = new Project(@“kayak.mpp”);
//Declare ChildTasksCollector class object
ChildTasksCollector collector = new ChildTasksCollector();
//Use TaskUtils to get all children tasks in RootTask
TaskUtils.Apply(prj.RootTask, collector, 0);
foreach (Task tsk in collector.Tasks)
{
Console.WriteLine("Task Id = " + tsk.Id + “, Task=” + tsk.Name);
List TaskEas = tsk.ExtendedAttribute;
foreach (ExtendedAttribute TaskEa in TaskEas)
{
Console.WriteLine(“Ex Field Name = " + TaskEa.AttributeDefinition.FieldName);
Console.WriteLine(“Value = " + TaskEa.Value.ToString());
}
Console.WriteLine(”___________________________________”);
}
}

Hi Kashif

When we read a plan we immediately look at the ExtendedAttributes collection to determine if the plan is using any custom columns. We then make decisions based on that fact. For most plans the ExtendedAttributes collection only contains columns that are actually being used. If no columns are being used it is blank (I have attached a sample plan that has an empty ExtendedAttributes collection).

The weird thing about the kayak.mpp plan is that it is handled differently to other plans where the ExtendedAttributes collection has much fewer elements in it.

Craig

Hi Craig,


I have analyzed the scenario again and found that its quite possible to create such a plan where the project contains collection of extended attributes definition but there is no value assigned to this extended attribute in any of the task. For testing I wrote a sample code (given below) which uses a template project. An extended attribute (Number1) definition is added in the Project but this attribute is not used for any of the task. In this case if we open this plan using Aspose.Tasks, it will show this attribute in the collection but no task is found having value for this attribute.

It seems that this particular MPP is created such that only definitions are added but these attributes are not used for any of the tasks. So it does not seem to be an issue with the Aspose.Tasks. Following code can be used to observe this behavior.

static public void CreateExtendedAttributes()
{
//create a project instance
Project prj = new Project(@“Template.mpp”);
List eads = prj.ExtendedAttributes;
if (eads == null)
{
eads = new List();
prj.ExtendedAttributes = eads;
}
// Create extended attribute definition
ExtendedAttributeDefinition ead = new ExtendedAttributeDefinition();
ead.FieldId = ((int)ExtendedAttributeTask.Number1).ToString();
ead.FieldName = “Number1”;
eads.Add(ead);

// Following code is disabled which adds value for attribute “Number1”
// Get zero index task
//Task tsk = (Task)prj.RootTask.Children[0];
//List eas = tsk.ExtendedAttribute;
//if (eas == null)
//{
// eas = new List();
// tsk.ExtendedAttribute = eas;
//}
//ExtendedAttribute ea = new ExtendedAttribute();
//ea.FieldId = ead.FieldId;
//ea.Value = “123”;
//eas.Add(ea);
prj.Save(@“New.mpp”, SaveFileFormat.MPP);

}