ExtendedAttributeDefinitionCreateLookupResourceDefinition Method (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.

Namespace:  Aspose.Tasks
Assembly:  Aspose.Tasks (in Aspose.Tasks.dll) Version: 21.5
Syntax
public static ExtendedAttributeDefinition CreateLookupResourceDefinition(
	CustomFieldType customFieldType,
	ExtendedAttributeResource fieldId,
	string alias
)

Parameters

customFieldType
Type: Aspose.TasksCustomFieldType
The specified CustomFieldType type.
fieldId
Type: Aspose.TasksExtendedAttributeResource
The specified ExtendedAttributeResource field ID.
alias
Type: SystemString
The specified String alias.

Return Value

Type: ExtendedAttributeDefinition
Created instance of the ExtendedAttributeDefinition class with specified customFieldType, fieldId and alias.
Examples
Use this example to create a custom field definition for a resource with lookup and then fill it with text values:
var resourceTextAttr = ExtendedAttributeDefinition.CreateLookupResourceDefinition(CustomFieldType.Text, ExtendedAttributeResource.Text27, "My custom field");
resourceTextAttr.AddLookupValue(new Value { Id = 1, Val = "Text value 1", Description = "Text value description 1" });
resourceTextAttr.AddLookupValue(new Value { Id = 2, Val = "Text value 2", Description = "Text value description 2" });
project.ExtendedAttributes.Add(resourceTextAttr);
Examples
Shows how to add extended attributes with lookups for assignments.
var project = new Project(DataDir + "Blank2010.mpp");

// Assign resource "1 TRG: Trade Group" to the "TASK 1" by creating a ResourceAssignment object.
var resource = project.Resources.GetById(1);
var task = project.RootTask.Children.GetById(1);
var assignment = project.ResourceAssignments.Add(task, resource);

// Create custom attribute definition with lookup.
var resExtendedAttributeDefinition = ExtendedAttributeDefinition.CreateLookupResourceDefinition(
    CustomFieldType.Cost,
    ExtendedAttributeResource.Cost5,
    "My lookup resource cost");
project.ExtendedAttributes.Add(resExtendedAttributeDefinition);

var firstValue = new Value { NumericValue = 1500, Description = "Val 1", Id = 1, Val = "1500" };
var secondValue = new Value { NumericValue = 2500, Description = "Val 2", Id = 2 };
resExtendedAttributeDefinition.AddLookupValue(firstValue);
resExtendedAttributeDefinition.AddLookupValue(secondValue);

// This value can be seen in "Resource usage" view of MS Project.
var attributeValue = resExtendedAttributeDefinition.CreateExtendedAttribute(firstValue);
assignment.ExtendedAttributes.Add(attributeValue);

// Create custom attribute definition with lookup.
var taskCostAttr = ExtendedAttributeDefinition.CreateLookupTaskDefinition(CustomFieldType.Cost, ExtendedAttributeTask.Cost4, "My lookup task cost");
project.ExtendedAttributes.Add(taskCostAttr);
var taskFirstValue = new Value { NumericValue = 18, Description = "Task val 1", Id = 3, Val = "18" };
var resSecondValue = new Value { NumericValue = 30, Description = "Task val 2", Id = 4 };
var taskWrongValue = new Value { NumericValue = 99, Description = "Task val Wrong", Id = 5, Val = "18" };

taskCostAttr.AddLookupValue(taskFirstValue);
resExtendedAttributeDefinition.AddLookupValue(resSecondValue);

// This value can be seen in "Task usage" view of MS Project.
assignment.ExtendedAttributes.Add(taskCostAttr.CreateExtendedAttribute(taskFirstValue));

// a wrong values can be removed later
taskCostAttr.RemoveLookupValue(taskWrongValue);

// working with project...
See Also