ExtendedAttributeTask &ValueList Not Showing Populated Drop-Down in MS Project

Hello!

Thank you for the quick response to my last question. I have another!

I am trying to use an existing Task "Column" (OutlineCode1) and alter it to show a drop-down list of values.

I am using an ExtendedAttributeDefinition (ExtendedAttributeTask.OutlineCode1).

My code is below.

Where I run my code (that copies a template *.mpp, adds resources and then alter this "column") the drop-down list of values (about 24 values) does NOT show when I make column OutlineCode1 visible in the Gantt view. The column "header" does show the Alias I set "MyColumnName", but the drop-down list is empty.

Can you assist?

private void AddMappingToProject(Project prj, MappingEntry m)
{
ExtendedAttributeDefinition ead = new ExtendedAttributeDefinition();

ead.FieldName = m.FieldName; // "OutlineCode1"
ead.Alias = m.MappingName; // "MyColumnName"
ead.FieldId = Convert.ToInt32(m.Field).ToString(); // m.Field = ExtendedAttributeTask.OutlineCode1
ead.AppendNewValues = false;
ead.RestrictValues = true;

int val = 0;
foreach (IdNameDescriptionValue i in m.ListItems)
{
string name = i.Name.Replace(",", "|").Replace(" ", " "); //clean-up name; just a string
Value v = new Value();
v.Description = name;
v.Id = val;
ead.ValueList.Add(v);
val += 1;
}

prj.ExtendedAttributes.Add(ead);
}

Hi Doug,


For an Extended Attribute to show multiple lookup values in the combo box, you need to assign a GUID to the extended attribute. Please try adding this to the extended attribution definition and share your feedback with us.

Code:

ExtendedAttributeDefinition ead = new ExtendedAttributeDefinition();


ead.FieldName = m.FieldName; // “OutlineCode1”

ead.Alias = m.MappingName; // “MyColumnName”

ead.FieldId = Convert.ToInt32(m.Field).ToString(); // m.Field = ExtendedAttributeTask.OutlineCode1

ead.AppendNewValues = false;

ead.RestrictValues = true;

ead.LookupUid = Guid.NewGuid().ToString();

Muhammad,


Thank you for the reply. Unfortunately, with the additional line of code (LookupUid), the result is the same - when I show the OutlineCode1 column in MS Project, the drop-down list is still empty. I also tried the highlighted lines below - same result.

Do you have any other suggestions?
ead.FieldName = m.FieldName; // “OutlineCode1”
ead.Alias = m.MappingName; // “MyColumnName”
ead.FieldId = Convert.ToInt32(m.Field).ToString(); // m.Field = ExtendedAttributeTask.OutlineCode1
ead.AppendNewValues = false;
ead.RestrictValues = true;
ead.LookupUid = Guid.NewGuid().ToString();
//ead.ElementType = ElementType.Assignment;
//ead.Guid = Guid.NewGuid().ToString();
//ead.ValuelistSortOrder = 1;
int val = 0;
foreach (IdNameDescriptionValue i in m.ListItems)
{
string name = i.Name.Replace(",", “|”).Replace(" ", " "); //clean-up name; just a string
Value v = new Value();
v.Description = name;
v.Id = val;
ead.ValueList.Add(v);
val += 1;
}

prj.ExtendedAttributes.Add(ead);

Thanks,


Doug

Muhammad,


As a follow-on, assuming we get this figured out, I have another question.

I would actually like these ExtendedAttributes to be associated with a ResourceAssignment, rather than a Task.

However, I did not see a way - I found no "ExtendedAttributeResourceAssignment.OutlineCode1 for example.

How can I have these ExtendedAttributes appear as columns on a ResourceAssignment (for example, in the TaskUsage View?

Thanks,

Doug

Muhammad,


I got it working! Here is code. (1) I was not assigning to v.Val (duh!) and (2) I needed to ensure the IDs in the list items (across multiple lists) were unique. I also recreated the ValueList before I began adding items.

ExtendedAttributeDefinition ead = new ExtendedAttributeDefinition();

ead.FieldName = m.FieldName; // “Text1”
ead.Alias = m.MappingName; // “MyColumnName”
ead.FieldId = Convert.ToInt32(m.Field).ToString(); // m.Field = ExtendedAttributeTask.Text1
ead.CfType = CustomFieldType.Text;
ead.LookupUid = Guid.NewGuid().ToString();

ead.AppendNewValues = false;
ead.RestrictValues = true;

ead.ValueList = new List();
foreach (IdNameDescriptionValue i in m.ListItems)
{
string name = i.Name.Replace(",", “|”).Replace(" ", " "); //clean-up name; just a string
Value v = new Value();
v.Val = name;
if (!m.HideDescription)
{
v.Description = i.Description;
}
v.Id = _ListItemID;
ead.ValueList.Add(v);
_ListItemID += 1;
}

prj.ExtendedAttributes.Add(ead);

Hi Doug,


We are glad to know that your issue is resolved and thank you for providing feedback. Please feel free to write us for any other query related to Aspose.Tasks.