How to select newly created extendedattribute in mpp file


#1

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.


#2

@ramyaakula,

Can you please share source mpp file so that we may further investigate to help you out.


#3

@Adnan.Ahmad,

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”.

Files.zip (70.0 KB)

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

#4

@Adnan.Ahmad,

How to set Predecessors value?

It is readonly , but if i want to set new value how?


#5

@ramyaakula,

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.


#6

Hello, ramyaakula.

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


#7

@mudassir.fayyaz,

I will check and update you.

Thanks.


#8

@vasiliysinitsyn

Thanks in advance, i will try.


#9

@vasiliysinitsyn

Thank You, it worked for me.