ExtendedAttributeDefinition Class

Represents an extended attribute definition associated with a project.
Inheritance Hierarchy
SystemObject
  Aspose.TasksExtendedAttributeDefinition

Namespace:  Aspose.Tasks
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.10
Syntax
public class ExtendedAttributeDefinition

The ExtendedAttributeDefinition type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleAlias
Gets or sets the alias of a custom field.
Public propertyCode exampleAppendNewValues
Gets or sets a value indicating whether new values added to a project are automatically added to the list.
Public propertyCode exampleAutoRollDown
Gets or sets a value indicating whether an automatic roll down to assignments is enabled.
Public propertyCode exampleCalculationType
Gets or sets the calculation type.
Public propertyCode exampleCfType
Gets the type of a custom field.
Public propertyCode exampleDefault
Gets or sets the default value in the list.
Public propertyCode exampleDefaultGuid
Gets or sets the Guid of the default lookup table entry.
Public propertyCode exampleElementType
Gets or sets the extended attribute is associated with a task, a resource or an assignment.
Public propertyCode exampleFieldId
Gets or sets corresponds to the project id of a custom field. Use string representation of a constant from ExtendedAttributeTask class to specify FieldId property.
Public propertyCode exampleFieldName
Gets the name of a custom field.
Public propertyCode exampleFormula
Gets or sets the formula that Microsoft Project uses to populate a custom task field.
Public propertyCode exampleGuid
Gets or sets the Guid of a custom field.
Public propertyCode exampleLookupUid
Gets a Guid of the lookup table associated with a custom field.
Public propertyCode exampleMaxMultiValues
Gets or sets the maximum number of values you can set in a pick list.
Public propertyCode exampleParentProject
Gets the parent project for the ExtendedAttributeDefinition instance.
Public propertyCode examplePhoneticsAlias
Gets or sets the phonetic pronunciation of the alias of a custom field.
Public propertyCode exampleRestrictValues
Gets or sets a value indicating whether the custom field values are restricted to values in the ValueList.
Public propertyCode exampleRollupType
Gets or sets the way rollups are calculated.
Public propertyCode exampleSecondaryGuid
Gets or sets the secondary guid of extended attribute.
Public propertyCode exampleSecondaryPid
Gets or sets the secondary PID of a custom field.
Public propertyCode exampleUserDef
Gets or sets a value indicating whether a custom field is user defined.
Public propertyCode exampleValueList
Gets the List<Value> ValueList.
Public propertyCode exampleValuelistSortOrder
Gets or sets the way value lists are sorted. Values are: 0=Descending, 1=Ascending.
Methods
  NameDescription
Public methodCode exampleAddLookupValue
Adds a value to the internal lookup list. This is a preferable way for manipulations with the ValueList.
Public methodCode exampleCreateExtendedAttribute
Creates a new extended attribute with the field ID which equals to this object's field ID value.
Public methodCode exampleCreateExtendedAttribute(Boolean)
Creates a new extended attribute with the field ID which equals to this object's field ID value and the specified flag value.
Public methodCode exampleCreateExtendedAttribute(DateTime)
Creates a new extended attribute with the field ID which equals to this object's field ID value and the specified date value.
Public methodCode exampleCreateExtendedAttribute(Decimal)
Creates a new extended attribute with the field ID which equals to this object's field ID value and the specified numeric value.
Public methodCode exampleCreateExtendedAttribute(String)
Creates a new extended attribute with the field ID which equals to this object's field ID value and the specified text value.
Public methodCode exampleCreateExtendedAttribute(Duration)
Creates a new extended attribute with the field ID which equals to this object's field ID value and the specified duration value.
Public methodCode exampleCreateExtendedAttribute(Value)
Creates new extended attribute linked with specified Value item.
Public methodStatic memberCode exampleCreateLookupResourceDefinition(ExtendedAttributeResource, String)
Factory method which creates an extended attribute definition with lookup. It has CalculationType equals to Lookup and can be used in Resources only. You are required to specify fieldId and alias when call this method. The field type is inferred from field id.
Public methodStatic memberCode exampleCreateLookupResourceDefinition(CustomFieldType, ExtendedAttributeResource, String)
Factory method which creates an extended attribute definition with lookup. It has CalculationType equals to Lookup and can be used in Resources only. You are required to specify customFieldType, fieldId and alias when call this method.
Public methodStatic memberCode exampleCreateLookupTaskDefinition(ExtendedAttributeTask, String)
Factory method which creates an extended attribute definition with lookup. It has CalculationType equals to Lookup and can be used in Tasks only. You are required to specify fieldId and alias when call this method. The field type is inferred from field id.
Public methodStatic memberCode exampleCreateLookupTaskDefinition(CustomFieldType, ExtendedAttributeTask, String)
Factory method which creates an extended attribute definition with lookup. It has CalculationType equals to Lookup and can be used in Tasks only. You are required to specify customFieldType, fieldId and alias when call this method.
Public methodStatic memberCode exampleCreateResourceDefinition(ExtendedAttributeResource, String)
Factory method which creates a simple extended attribute definition, which Microsoft Project shows as "None". It has CalculationType equals to None and can be used in Resource only. You are required to specify fieldId and alias when call this method. The field type is inferred from field id.
Public methodStatic memberCode exampleCreateResourceDefinition(CustomFieldType, ExtendedAttributeResource, String)
Factory method which creates a simple extended attribute definition, which Microsoft Project shows as "None". It has CalculationType equals to None and can be used in Resource only. You are required to specify customFieldType, fieldId and alias when call this method.
Public methodStatic memberCode exampleCreateTaskDefinition(ExtendedAttributeTask, String)
Factory method which creates a simple extended attribute definition, which Microsoft Project shows as "None". It has CalculationType equals to None and can be used in Tasks only. You are required to specify fieldId and alias when calling this method. The field type is inferred from field id.
Public methodStatic memberCode exampleCreateTaskDefinition(CustomFieldType, ExtendedAttributeTask, String)
Factory method which creates a simple extended attribute definition, which Microsoft Project shows as "None". It has CalculationType equals to None and can be used in Tasks only. You are required to specify customFieldType, fieldId and alias when calling this method.
Public methodCode exampleEquals
Returns a flag indicating whether this instance is equal to the specified object.
(Overrides ObjectEquals(Object).)
Protected methodFinalize (Inherited from Object.)
Public methodCode exampleGetHashCode
Returns a hash code for the instance of the ExtendedAttributeDefinition class.
(Overrides ObjectGetHashCode.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodCode exampleRemoveLookupValue
Removes a value from the internal lookup list. This is a preferable way for manipulations with the ValueList.
Public methodToString (Inherited from Object.)
Examples
Shows how to use common math functions with extended attributes.
public static void EvaluateChoose()
{
    var project = CreateTestProjectWithCustomField();

    // Set Formula
    project.ExtendedAttributes[0].Formula = "Choose(3, \"This is a\", \"right\", \"choice\")";

    // Print extended attribute value
    var task = project.RootTask.Children.GetById(1);
    Console.WriteLine(task.ExtendedAttributes[0].TextValue);
}

public static void EvaluateIsNumeric()
{
    string[] numericFormulas =
        {
            "IsNumeric('AAA')", @"IsNUmeric(1)", "IsNumeric(1<0)", "IsNumeric(\"1.1\")", "IsNumeric(Choose((2 + Sgn(2^-3)), 123, \"one two three\"))"
        };

    var project = CreateTestProjectWithCustomField();

    foreach (var numericFormula in numericFormulas)
    {
        // Set Formula
        project.ExtendedAttributes[0].Formula = numericFormula;

        // Print extended attribute value
        var task = project.RootTask.Children.GetById(1);
        Console.WriteLine(task.ExtendedAttributes[0].TextValue);
    }
}

public static void EvaluateSwitch()
{
    var project = CreateTestProjectWithCustomField();

    // Set Formula
    project.ExtendedAttributes[0].Formula = "Switch( 0 < 1, \"0 is lesser than 1\", 0 > 1, \"0 is greater than 1\")";

    // Print extended attribute value
    var task = project.RootTask.Children.GetById(1);
    Console.WriteLine(task.ExtendedAttributes[0].TextValue);
}

public static Project CreateTestProjectWithCustomField()
{
    var project = new Project();
    var definition = ExtendedAttributeDefinition.CreateTaskDefinition(CustomFieldType.Text, ExtendedAttributeTask.Text1, "Custom Field");
    project.ExtendedAttributes.Add(definition);

    var task = project.RootTask.Children.Add("Task");

    var attribute = definition.CreateExtendedAttribute();
    task.ExtendedAttributes.Add(attribute);
    return project;
}
See Also