Trouble with getting multiple values in custom column task valuelist

When I execute the following code no error occurs, but when checking the custom column value the only value that appears is the first value (Test Value 1). There is no option to select the second value (Test value 2). I am guessing I should see a drop down with both values listed. Is this incorrect or am I missing something to make that happen.

Using Task 8.5 and MS Project 2010

Thanks for the help

Dim project As New Project(dataDir & "base.mpp")


Dim newFile As String = dataDir & "base.mpp"
Dim resultFile As String = dataDir & "TESTNEW.mpp"



' #Region "task attributes"

Dim taskTextAttr As New ExtendedAttributeDefinition()
taskTextAttr.Alias = "New text3 attribute"
taskTextAttr.FieldName = "Text3"
taskTextAttr.FieldId = Convert.ToInt32(ExtendedAttributeTask.Text3).ToString
taskTextAttr.ElementType = ElementType.Task
taskTextAttr.CfType = CustomFieldType.Text

Dim textVal As New Value()
textVal.Id = 1
textVal.Description = "Text value descr"
textVal.Val = "Text value1"

Dim textVal2 As New Value()
textVal2.Id = 2
textVal2.Description = "Text value 2 descr"
textVal2.Val = "Text value2"

taskTextAttr.ValueList.Add(textVal)
taskTextAttr.ValueList.Add(textVal2)

project.ExtendedAttributes.Add(taskTextAttr)
project.Save(resultFile, Aspose.Tasks.Saving.SaveFileFormat.MPP)

Hi,


Thank you for posting your query.

Please try the following code sample that includes setting a GUID for lookup values for defining the extended attributes. Please share your feedback with us if you have further inquiry for this issue.

Code:



Dim project As New Project(“New Project 2010.mpp”)


Dim textAttr As New ExtendedAttributeDefinition()

textAttr.FieldId = ExtendedAttributeTask.Text1.ToString(“D”)

textAttr.[Alias] = “New text attribute”

textAttr.CfType = CustomFieldType.Text

textAttr.LookupUid = Guid.NewGuid().ToString()


textAttr.ValueList = New List(Of Value)()

Dim v As New Value()

v.Val = “TEXT VALUE1”

v.Description = “Text value description”

v.Id = 1


textAttr.ValueList.Add(v)


v = New Value()

v.Val = “TEXT VALUE2”

v.Description = “Text value description”

v.Id = 2

textAttr.ValueList.Add(v)


project.ExtendedAttributes.Add(textAttr)


project.Save(“Combo.mpp”, SaveFileFormat.MPP)
It does not work in my case.

string newFile = @"c:\users\sanjay.quadwave\documents\visual studio 2015\Projects\MyTasks\ConsoleApplication1\MigrationPlanTemplate.mpp";

string resultFile = "C:\\OutputMPP.mpp";

Project project = new Project(newFile);

int fieldId = 188743731;

// Add new text3 extended attribute and one text value

ExtendedAttributeDefinition taskTextAttr = new ExtendedAttributeDefinition();

taskTextAttr.Alias = "New text3 attribute";

taskTextAttr.FieldName = "Text3";

taskTextAttr.FieldId = ExtendedAttributeTask.Text3.ToString("D");

taskTextAttr.ElementType = ElementType.Task;

taskTextAttr.CfType = CustomFieldType.Text;

project.ExtendedAttributes.Add(taskTextAttr);

Value textVal = new Value();

textVal.Id = 1;

textVal.Description = "Text value descr";

textVal.Val = "Text value1";

taskTextAttr.ValueList.Add(textVal);

// Add new cost1 extended attribute and two cost values


ExtendedAttributeDefinition taskCostAttr = new ExtendedAttributeDefinition();


taskCostAttr.Alias = “New cost1 attribute”;


taskCostAttr.FieldName = “Cost1”;


taskCostAttr.ElementType = ElementType.Task;


taskCostAttr.CfType = CustomFieldType.Cost;


taskCostAttr.FieldId = ExtendedAttributeTask.Cost1.ToString(“D”);


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

Value costVal1 = new Value();

costVal1.Id = 2;

costVal1.Description = "Cost value 1 descr";

costVal1.Val = "99900";

Value costVal2 = new Value();

costVal2.Id = 3;

costVal2.Description = "Cost value 2 descr";

costVal2.Val = "11100";

taskCostAttr.ValueList.Add(costVal1);

taskCostAttr.ValueList.Add(costVal2);

project.ExtendedAttributes.Add(taskCostAttr);

// Add new task and assign attribute value

Task task = project.RootTask.Children.Add("New task");

ExtendedAttribute taskAttr = new ExtendedAttribute();

taskAttr.AttributeDefinition = taskCostAttr;

taskAttr.Value = "99900";

taskAttr.FieldId = taskCostAttr.FieldId;

task.ExtendedAttributes.Add(taskAttr);

ExtendedAttribute taskAttrText = new ExtendedAttribute();

taskAttrText.AttributeDefinition = taskTextAttr;

taskAttrText.Value = "99900";

taskAttrText.FieldId = taskTextAttr.FieldId;

task.ExtendedAttributes.Add(taskAttrText);

//Save the project as MPP project file


project.Save(resultFile, Aspose.Tasks.Saving.SaveFileFormat.MPP);

Hi Sunjay,


FieldId and LookupUid are added in the code and modified code is given below for your reference. This will create extended attributes with pre-defined set of values which are visible in MSP.


Dim path As String = “”

Dim newFile As String = path & Convert.ToString(“Blank2010.mpp”)


Dim resultFile As String = path & Convert.ToString(“UserOutputMPP.mpp”)


Dim project As New Project(newFile)


’ Add new text3 extended attribute and one text value


Dim taskTextAttr As New ExtendedAttributeDefinition()


taskTextAttr.[Alias] = “New text3 attribute”


taskTextAttr.FieldName = “Text3”


taskTextAttr.FieldId = Convert.ToInt32(ExtendedAttributeTask.Text3).ToString()

taskTextAttr.LookupUid = Guid.NewGuid().ToString()

taskTextAttr.ElementType = ElementType.Task


taskTextAttr.CfType = CustomFieldType.Text


project.ExtendedAttributes.Add(taskTextAttr)


Dim textVal As New Value()


textVal.Id = 1


textVal.Description = “Text value descr”


textVal.Val = “Text value1”


taskTextAttr.ValueList.Add(textVal)


’ Add new cost1 extended attribute and two cost values


Dim taskCostAttr As New ExtendedAttributeDefinition()


taskCostAttr.[Alias] = “New cost1 attribute”


taskCostAttr.FieldName = “Cost1”


taskCostAttr.ElementType = ElementType.Task


taskCostAttr.CfType = CustomFieldType.Cost



taskCostAttr.FieldId = Convert.ToInt32(ExtendedAttributeTask.Cost1).ToString()

taskCostAttr.LookupUid = Guid.NewGuid().ToString()


Dim costVal1 As New Value()


costVal1.Id = 2


costVal1.Description = “Cost value 1 descr”


costVal1.Val = “99900”


Dim costVal2 As New Value()


costVal2.Id = 3


costVal2.Description = “Cost value 2 descr”


costVal2.Val = “11100”


taskCostAttr.ValueList.Add(costVal1)


taskCostAttr.ValueList.Add(costVal2)


project.ExtendedAttributes.Add(taskCostAttr)


’ Add new task and assign attribute value


Dim task As Aspose.Tasks.Task = project.RootTask.Children.Add(“New task”)


Dim taskAttr As New ExtendedAttribute()


taskAttr.AttributeDefinition = taskCostAttr


taskAttr.Value = “99900”


taskAttr.FieldId = taskCostAttr.FieldId

taskAttr.ValueGuid = Guid.NewGuid().ToString()


task.ExtendedAttributes.Add(taskAttr)


Dim taskAttrText As New ExtendedAttribute()


taskAttrText.AttributeDefinition = taskTextAttr


taskAttrText.Value = “Text value1”


taskAttrText.FieldId = taskTextAttr.FieldId

taskAttrText.ValueGuid = Guid.NewGuid().ToString()

task.ExtendedAttributes.Add(taskAttrText)


'Save the project as MPP project file


project.Save(resultFile, Aspose.Tasks.Saving.SaveFileFormat.MPP)


However, I have observed, that values assigned to these attributes for a task are not visible in MSP. This issue is logged under Id: TASKS-34186 for further investigation by the product team. I shall write here as soon some feedback is received in this regard.

The issues you have found earlier (filed as TASKS-34186) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.