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

Free Support Forum - aspose.com

Extended Attributes

Hi,
Once again upgrading from aspose tasks 19.3 to 22.3 and finding a difference in the evaluation of the following line of code which is checking to see if extended attribute ID exists:

if (_myMSProject.ExtendedAttributes.GetById(Convert.ToInt32(ExtendedAttributeTask.Text3.ToString(“D”))) == null)

In 19.3, first time through code, it evaluates to ‘null’ and correctly executes the code inside the If statement.

In 22.3, first time through code, the statement finds the attribute and does not go into the If statement.

What is the correct way to check for the existence of the extended attribute ID in 22.3 as I would expect it to be ‘null’ the first time through and need it to execute code inside the if statement.

Thanks

@liesa.collier,
could you attach a sample .mpp file so we can investigate why
(_myMSProject.ExtendedAttributes.GetById(Convert.ToInt32(ExtendedAttributeTask.Text3.ToString(“D”))) == null) is evaluated differently?

This is a correct way to check for the existence of the extended attribute definition in a project.

Also you could use shorter syntax:
_myMSProject.ExtendedAttributes.GetById((int)ExtendedAttributeTask.Text3).

Hi,

I have attached a sample mpp but our problem is before the mpp is created. When creating the .mpp, 19.3 evaulates to null and 22.3 finds the id. On subsequent debug sessions after the mpp is created, the behaviour is the same.

Just to add some more detail to this one:
I have found that the initial _myMSProject is instantiated from the template file. The extended attributes inherited from the template file are different in 19.3 and 22.3. They are indentified in the attachment ‘TemplateDifferences’. The reason why 19.3 doesn’t find the id is because it doesn’t exist when the object is instantiated from the template file but when the object is instantiated in version 22.3 from the template file, that id exists. That is what is causing my issue. Why is there differences in the initial extended attribute list when the object is instatiated in versions 19.3 and 22.3? WBSTemplate.zip (43.5 KB)

Here is the Template file that we are using in both versions 19.3 and 22.3

Template Differences.zip (9.8 KB)

Finally, here is a sample mpp file

823_971___CHKMAJOR.zip (45.7 KB)

@liesa.collier,

Without going into details, between 19.9 and 22.3 we changed the way Aspose.Tasks reads Extended Attributes in order to make the resulting collection (project.ExtendedAttributes) contain the same attributes as in MS Project’s representation.
You can check which definitions are present in your template by opening WBSTemplate.mpp in Microsoft Project and saving it to .xml file. Microsoft Project writes definitions to tag:

		<ExtendedAttribute>
			<FieldID>188743731</FieldID>
			<FieldName>Text1</FieldName>
...
		</ExtendedAttribute>
		<ExtendedAttribute>
			<FieldID>188743737</FieldID>
			<FieldName>Text3</FieldName>
...
		</ExtendedAttribute>
		<ExtendedAttribute>
			<FieldID>188743740</FieldID>
			<FieldName>Text4</FieldName>
etc.

Thus 24.4 has more correct representation of extended attributes.

Hi,
Thanks for the xml tip. I can see the extendedattribute collection in 19.3 seemed to have reversed some of the fieldid and secondpid. That may explain why it never found the field in version 19.3. However, when I open the template xml created from version 22.3, I still cannot find the id of ‘188743737’ (fieldname = ‘text3’) in the template file. When I instatiate the project object and expand the extendedattribute collection in visual studio, the id of ‘188743737’ is in that collection. So, why do the collection show different from the xml file? Also, from your screenshot, you are able to see the ‘text3’ field in the xml file, but I do not see it. That is one of the fields I am searching for. Your previous comment references 24.4, should that have been 22.4? Maybe we should test out version 22.4 to see if the extended attributes are more correct?

@liesa.collier

I saved “WBSTemplate.mpp” to XML using MS Project or using Aspose.Tasks 22.3

I see that the resulting XML files contain the following lines:

<ExtendedAttribute>
    <FieldID>188743737</FieldID>
    <FieldName>Text3</FieldName>
</ExtendedAttribute>

(xml node ‘Project/ExtendedAttributes’)

These lines are also present in the screenshot.

I used 22.4 because it’s the latest version. 22.3 should have the same behavior regarding handling of the extended attributes.

WBSTemplate - Backup_2022_04_2021_Project.zip (3.2 KB)

Here is the wbstemplate.xml file which I opened using 22.3 and Project 2021. That field (text3) is not in there.

@liesa.collier,

Yes, your file doesn’t contain Text3 definition.
Which .MPP file did you use to generate ‘wbstemplate.xml’ ? Could you attach it ?

I used .MPP file from attached WBSTemplate.zip:
https://forum.aspose.com/uploads/discourse_instance3/62717

WBSTemplate.zip (3.1 KB)

Same file as above, I just renamed it. Attached once again.
I just used the one you referenced, opened in Project 2021, (aspose 22.3), saved as xml and no field called text3 in it.

@liesa.collier ,
I’ve checked once again and now MS Projects doesn’t emit Text3 definition, but Aspose.Tasks still emit Text3 definition to xml file.

Anyway, raw data in MPP file contains definition of Text3 attribute. So project.ExtendedAttributes collection contains Text3.

Could you tell what kind of logic depends on “_myMSProject.ExtendedAttributes.GetById(Convert.ToInt32(ExtendedAttributeTask.Text3.ToString(“D”))) == null” condition?