I can able to create new extended attribute / custom field.
After opening newly created mpp, i can see template with old column headings only,
How to add new column to mpp template column headings which is newly created extended attribute / custom field immediately after creating new attribute.
PFA my empty mpp template - “BlankTemplateProject.mpp”, and i need to create new mpp file with sample data as per mpp file - “PSF MPP template sample for MSF.mpp”.
“PSF MPP template sample for MSF.mpp”. file contains some new customized columns , so i created those new columns uisng extendedattribute code and they are appearing in lookup i.e, in new columns dropdown.
but when i create new columns, those should be shown on column heading by default after saving file, which is not happening.
Please find my code sample,
License lic = new License();
lic.SetLicense(@"C:\Aspose\Licenses\Aspose.Tasks.lic");
Project project = new Project(@"C:\Ramya\MPP\Old\BlankTemplateProject.mpp");
ExtendedAttributeDefinition myTextAttributeDefinition = project.ExtendedAttributes.GetById((int)ExtendedAttributeTask.Text1);
// If the Custom field doesn't exist in Project, create it
if (myTextAttributeDefinition == null)
{
myTextAttributeDefinition = ExtendedAttributeDefinition.CreateTaskDefinition(ExtendedAttributeTask.Text1, "My text field");
project.ExtendedAttributes.Add(myTextAttributeDefinition);
}
//Create a new task
Aspose.Tasks.Task task = project.RootTask.Children.Add("Engagement Dates");
ExtendedAttribute taskAttribute = myTextAttributeDefinition.CreateExtendedAttribute();
taskAttribute.TextValue = "Engagement Text details";
task.ExtendedAttributes.Add(taskAttribute);
task.Set(Tsk.Start, new DateTime(2018, 3, 12));
//task.Set(Tsk.Finish, new DateTime(2019, 4, 1));
task.Set(Tsk.Duration, project.GetDuration(30, TimeUnitType.Day));
project.Save(@"C:\Ramya\MPP\New\SDM_NewMPP_WithSampleData.mpp", SaveFileFormat.MPP);
I have observed your requirements and suggest you to please visit following thread link for your more about working with extended attribute in MPP file.
Do you want to add columns for the added extended attribute to the view using code?
If so, you can modify your example in the following way:
project.DefaultView.Table.TableFields.Add(new TableField { Field = Field.TaskText1, Title = “Title of my text field”});
project.Save(@“C:\Ramya\MPP\New\SDM_NewMPP_WithSampleData.mpp”, new MPPSaveOptions { WriteViewData = true} );