Add a ExtendedAttribute and make it visible in MSProject

Hi,

I should export data of a Gantt to MSProject, but I need to add a “Description” field.

So
I followed the guide to add a ExtendedAttribute and partly working, because is actually written in XML output, but when I opened the XML file in
MSProject the custom field is not visible.
However if I manually add the field “Description (Text1)” I see the field values that I set in the source code.

There is a way to make the field visible when the XML file is open in MSProject?

This is the code I used:

Dim attr As ExtendedAttribute
Dim eas As ArrayList
Dim ead As ExtendedAttributeDefinition
Dim eads As ArrayList
eads = prj.ExtendedAttributes
If eads Is Nothing Then
eads = New ArrayList()
prj.ExtendedAttributes = eads
End If
ead = New ExtendedAttributeDefinition()
ead.FieldId = CType(ExtendedAttributeTask.Text1, Integer).ToString
ead.Alias = "Description"
eads.Add(ead)
For Each row As DataRow In dtTasks.Rows
tsk = New Task(row("IDNRR"))
tsk.Uid = row("Uid")
tsk.Start = row("Start")
tsk.DurationFormat = TimeUnitType.Day
tsk.Duration = row("Duration")
eas = tsk.ExtendedAttribute
If eas Is Nothing Then
eas = New ArrayList()
tsk.ExtendedAttribute = eas
End If
attr = New ExtendedAttribute()
attr.FieldId = ead.FieldId
attr.Value = row("Description").ToString
eas.Add(attr)
rootTsk.Children.Add(tsk)
Next

Hi Marco,


We need a couple of days to investigate the issue. Sorry for inconvenience.

Hi Marco,

Unfortunately I was not able to repeat the issue on my side.

I used a code below and test data from attachment:

Imports Aspose.Tasks
Module Module1
Sub Main()
Dim prj As Project
Dim reader As ProjectReader
Dim writer As ProjectWriter
Dim ead As ExtendedAttributeDefinition
Dim ea As ExtendedAttribute
'read project data from xml
reader = New ProjectReader()
prj = reader.Read("project.xml")
'add extended attribute definition
ead = New ExtendedAttributeDefinition()
ead.FieldName = "Text1"
ead.Alias = "Description"
ead.FieldId = CType(ExtendedAttributeTask.Text1, Integer).ToString
prj.ExtendedAttributes = New ArrayList()
prj.ExtendedAttributes.Add(ead)
For Each task As Task In prj.RootTask.Children
task.ExtendedAttribute = New ArrayList()
ea = New ExtendedAttribute()
ea.FieldId = ead.FieldId
ea.Value = String.Format("Description of '{0}'.", task.Name)
task.ExtendedAttribute.Add(ea)
Next
'write to xml
writer = New ProjectWriter()
writer.Write(prj, "project_res.xml", TasksDataFormat.XML)
End Sub
End Module

As a result I can open the resulting XML file by MS Project 2007, add the Text1 column to the Gantt Chart view (insert column) and see the data. In case if the extended attribute definition’s alias was assigned I can see the description in task’s custom fields tab as well.

Please note, that the Text1 column can not be made visible by default as XML format does not contain any current view settings.