I need Text1 lookup options such that once project is created and extended attribute is added with some predefined lookup options, it should allow my customers to open it in MSP and add addtional values for the lookup table. Can you provide me some sample code where extended attribute with lookup table can be added along with the option to add new lookup values in the project? Also I dont want to allow user to add new values in the lookup table. What option should I use? Is there any read-only mode for this purpose?
Maria.Shahid:
As for your inquiry regarding restricting user from adding lookup values, this does not seem to be supported with Microsoft Project and there is no such feature in the API as well.
Hi George,
<div style=“color: rgb(0, 0, 0); font-family: “Times New Roman”; font-size: medium; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;”>
static private void SampleCode()
{
Project project = new Project();
OutlineCodeDefinition textOutline = new OutlineCodeDefinition();
project.OutlineCodes.Add(textOutline);
textOutline.OnlyTableValuesAllowed = true;//NOTE THIS LINE
// add a mask for text field
OutlineMask mask = new OutlineMask();
mask.Type = MaskType.Characters;
textOutline.Masks.Add(mask);
OutlineValue textValue1 = new OutlineValue();
textValue1.Value = “Text value1”;
textValue1.ValueId = 1;
textValue1.Type = OutlineValueType.Text;
textValue1.Description = “Text value descr”;
textValue1.FieldGuid = Guid.NewGuid().ToString().ToUpper();
textOutline.Values.Add(textValue1);
OutlineValue textValue2 = new OutlineValue();
textValue2.Value = “Text value2”;
textValue2.ValueId = 2;
textValue2.Type = OutlineValueType.Text;
textValue2.Description = “Text value descr”;
textValue2.FieldGuid = Guid.NewGuid().ToString().ToUpper();
textOutline.Values.Add(textValue2);
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);
// Add new task and assign attribute value
Task task = project.RootTask.Children.Add(“New task”);
ExtendedAttribute taskAttrText = taskTextAttr.CreateExtendedAttribute();
task.ExtendedAttributes.Add(taskAttrText);
project.Save(“SavedProject4.xml”, SaveFileFormat.XML);
}
Hi,
Hi George,
The issues you have found earlier (filed as TASKSNET-1790) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by kashif.iqbal
The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan