Extended Duration1-10 fields are always displayed in hours when added, regardless of the selected format


#1

public class Creator
{
private readonly Project asposeProject;

	public Creator(Project asposeProject)
	{
		this.asposeProject = asposeProject;
	}

	public void Run()
	{
		ExtendedAttributeDefinition myTextAttributeDefinition = asposeProject.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");
			asposeProject.ExtendedAttributes.Add(myTextAttributeDefinition);
		}

		// Generate Extended Attribute from definition
		ExtendedAttribute text1TaskAttribute = myTextAttributeDefinition.CreateExtendedAttribute();

		text1TaskAttribute.TextValue = "Text attribute value";

		// Add extended attribute to task
		Task task = asposeProject.RootTask.Children.Add("Task 1");
		task.ExtendedAttributes.Add(text1TaskAttribute);

		// Define a duration attribute without lookup.
		ExtendedAttributeDefinition taskDurationAttributeDefinition = ExtendedAttributeDefinition.CreateTaskDefinition(ExtendedAttributeTask.Duration1, "New Duration");
		asposeProject.ExtendedAttributes.Add(taskDurationAttributeDefinition);

		// Add new task and assign duration value to the previously defined duration attribute.
		
		ExtendedAttribute durationExtendedAttribute = taskDurationAttributeDefinition.CreateExtendedAttribute();

		durationExtendedAttribute.DurationValue = asposeProject.GetDuration(3.0, TimeUnitType.ElapsedDay);
		task.ExtendedAttributes.Add(durationExtendedAttribute);

		Task task2 = asposeProject.RootTask.Children.Add("Task 2");
		// Generate Extended Attribute from definition
		ExtendedAttribute text1TaskAttribute2 = myTextAttributeDefinition.CreateExtendedAttribute();
		text1TaskAttribute2.TextValue = "Text attribute value2";
		task2.ExtendedAttributes.Add(text1TaskAttribute2);

		ExtendedAttribute durationExtendedAttribute2 = taskDurationAttributeDefinition.CreateExtendedAttribute();

		durationExtendedAttribute2.DurationValue = asposeProject.GetDuration(5.0, TimeUnitType.ElapsedMinute);
		task2.ExtendedAttributes.Add(durationExtendedAttribute2);

		asposeProject.Save("CreateExtendedAttributes_out.mpp", SaveFileFormat.MPP);
	}
}

#2

@val26,

I have observed the sample code shared by you and request you to please share the details of issue or requirements on your end that you are looking in Aspose.Tasks to offer you. Please also provide the source file, generated and desired output file for reference as well.


#3

here is an example of the solution used. From this solution removed the license file “Aspose.Tasks.lic”, it must be added.ConsoleProject.zip (48.5 KB)


#4

@val26,

I have observed the requirements shared. An issue with ID TASKSNET-3583 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be addressed.