// Create new project System::SharedPtr project = System::MakeObject(dataDir + u"Blank2010.mpp"); // Assign resource "1 TRG: Trade Group" to the "TASK 1" by creating a ResourceAssignment object. System::SharedPtr resource = project->get_Resources()->GetById(1); System::SharedPtr task = project->get_RootTask()->get_Children()->GetById(1); System::SharedPtr assignment = project->get_ResourceAssignments()->Add(task, resource); // Create custom attribute definition with lookup. System::SharedPtr resCostAttr = ExtendedAttributeDefinition::CreateLookupResourceDefinition(Aspose::Tasks::CustomFieldType::Cost, Aspose::Tasks::ExtendedAttributeResource::Cost5, u"My lookup resource cost"); project->get_ExtendedAttributes()->Add(resCostAttr); auto value1 = [&]{ auto tmp_0 = System::MakeObject(); tmp_0->set_NumericValue(1500); tmp_0->set_Description(u"Val 1"); tmp_0->set_Id(1); tmp_0->set_Val(u"1500"); return tmp_0; }(); resCostAttr->AddLookupValue(value1); resCostAttr->AddLookupValue([&]{ auto tmp_1 = System::MakeObject(); tmp_1->set_NumericValue(2500); tmp_1->set_Description(u"Val 2"); tmp_1->set_Id(2); return tmp_1; }()); // This value can be seen in "Resource usage" view of MS Project. auto attributeValue = resCostAttr->CreateExtendedAttribute(value1); assignment->get_ExtendedAttributes()->Add(attributeValue); // Create custom attribute definition with lookup. System::SharedPtr taskCostAttr = ExtendedAttributeDefinition::CreateLookupTaskDefinition(Aspose::Tasks::ExtendedAttributeTask::Cost4, u"My lookup task cost"); project->get_ExtendedAttributes()->Add(taskCostAttr); auto taskLookupValue1 = [&]{ auto tmp_2 = System::MakeObject(); tmp_2->set_NumericValue(18); tmp_2->set_Description(u"Task val 1"); tmp_2->set_Id(3); tmp_2->set_Val(u"18"); return tmp_2; }(); taskCostAttr->AddLookupValue(taskLookupValue1); resCostAttr->AddLookupValue([&]{ auto tmp_3 = System::MakeObject(); tmp_3->set_NumericValue(30); tmp_3->set_Description(u"Task val 2"); tmp_3->set_Id(4); return tmp_3; }()); // This value can be seen in "Task usage" view of MS Project. assignment->get_ExtendedAttributes()->Add(taskCostAttr->CreateExtendedAttribute(taskLookupValue1)); project->Save(dataDir + u"AddExtendedAttributesToRAWithLookUp_out.mpp", Aspose::Tasks::Saving::SaveFileFormat::MPP);