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

Free Support Forum - aspose.com

Extended Attribute Definition - Lookup option not selected after adding to values list

Hi,


I’m adding values to the values list of an extended attribute definition as outlined in Aspose documentation sample. The lookup values are added, however, when I view the custom field via MS Project the “Lookup” radio button is not selected. Should adding values to the value list auto select this option? Or is there additional logic that needs to be added? See code below:


Project _project = new Project("C:\\WBSTemplate.mpp");// Create a new project task

ExtendedAttributeDefinition taskTextAttr = new ExtendedAttributeDefinition();

taskTextAttr.Alias = "New text3 attribute";

taskTextAttr.FieldName = "Text3";

taskTextAttr.ElementType = ElementType.Task;

taskTextAttr.CfType = CustomFieldType.Text;

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

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

_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 a task to see the result in MSP

Task task = _project.RootTask.Children.Add("Task");

foreach (ExtendedAttributeDefinition ea in _project.ExtendedAttributes)

{

task.ExtendedAttributes.Add(_project.ExtendedAttributes.GetById(Convert.ToInt32(ea.FieldId)).CreateExtendedAttribute());

}

MPPSaveOptions mppSaveOptions = new MPPSaveOptions();

mppSaveOptions.WriteViewData = true;

// The result of opening of saved project in MSP2010 is in attached screenshot

_project.Save("C:\\WBS\\LIVE\\1116_16\\Project1.mpp", mppSaveOptions);



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 posting your inquiry,

We have used your sample code and a sample code at our end as well for testing this issue. In both cases, the radio button of Lookup is shown selected. Can you please test this with the sample input file from our end as attached here “New Project 2010.mpp” and share your feedback with us? Please also share your sample input file and a screenshot of the problem with us for our reference.

Code Sample From Our End:

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);

// 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);

//Save the project as MPP project file
project.Save(“result.mpp”, SaveFileFormat.MPP);

Hi Muhammad,

I’ve tried the sample code you’ve provided and it works as expected. However, the problem seems to arise when I add both a number and a duration attribute at the same time. Once I do that the lookup radio button is not auto selected (but does contain the values list) and the neither of the formulas are added to the MPP file.

I've used the New Project 2010.mpp file that you attached and I've attached the output from my end (Project1.mpp).

Sample code provided and modified to include a Number and Duration attribute:

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 Number Attribute

ExtendedAttributeDefinition myTaskNumberAttr = new ExtendedAttributeDefinition();

myTaskNumberAttr.Alias = "Number Test";

myTaskNumberAttr.CfType = CustomFieldType.Number;

myTaskNumberAttr.FieldId = ExtendedAttributeTask.Number19.ToString("D");

myTaskNumberAttr.Formula = "(([Number13]-1)*48)+([Number18])";

project.ExtendedAttributes.Add(myTaskNumberAttr);

//New Duration Attribute

ExtendedAttributeDefinition myTaskDurrationAttr = new ExtendedAttributeDefinition();

myTaskDurrationAttr.Alias = "Duration Test";

myTaskDurrationAttr.CfType = CustomFieldType.Duration;

myTaskDurrationAttr.FieldId = ExtendedAttributeTask.Duration10.ToString("D");

myTaskDurrationAttr.Formula = "[Number19] * 480";

project.ExtendedAttributes.Add(myTaskDurrationAttr);

// 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);

//New Number Attribute

ExtendedAttribute taskAttrNumber = myTaskNumberAttr.CreateExtendedAttribute();

task.ExtendedAttributes.Add(taskAttrNumber);

//New Duration Attribute

ExtendedAttribute taskAttrDuration = myTaskDurrationAttr.CreateExtendedAttribute();

task.ExtendedAttributes.Add(taskAttrDuration);

MPPSaveOptions mppSaveOptions = new MPPSaveOptions();

mppSaveOptions.WriteViewData = true;

//// The result of opening of saved project in MSP2010 is in attached screenshot

project.Save("Result.mpp", mppSaveOptions);


Thanks, Calvin

Hi Calvin,


Thank you for providing detailed description of the error.

We have re-produced this issue at our end and logged under Id: TASKS-34486 for further investigation by the product team. Product team will analyze this issue and provide feedback which will be forwarded to you.

Hi Kashif,


What’s the normal turnaround time for a reported issue that becomes a TASK to be corrected and available?

As it sits right now I cannot manually add the required formulas to the template MPP file and have them copied to the result MPP file either. Is there another work around that I might be able to try?

Thanks, Calvin

Hi Calvin,

We usually do monthly product releases and resolution of an issue depends on the complexity involved. Normally, an issue reported well before the product release time is expected to be resolved in the upcoming release in case it doesn’t involve complexity. We are sorry but we couldn’t find a work around method to achieve this. Our product team is look into this issue and we’ll update you here once there is some information available in this regard.

Hi Kashif,


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

Thanks, Calvin

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


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