Proper values for each CustomFieldType


#1

We recently upgraded to version 19.9 and once I compiled I noticed you all changed ExtendedAttribute so that it no longer has a simple .Value. Instead it had a series of Values based on the type of the CustomField.

My problem is that the documentation is lacking. Some of the mappings are clear, but others are not. Specifically what value should I be getting for OutlineCode, RBS and Null type?

      switch (attribute.AttributeDefinition.CfType)
      {
        case CustomFieldType.Cost:
        case CustomFieldType.Number:
              return (double)attribute.NumericValue;
        case CustomFieldType.Date:
        case CustomFieldType.Start:
        case CustomFieldType.Finish:
              return attribute.DateValue;
        case CustomFieldType.Duration:
              var dValue = attribute.DurationValue;
              return dValue.TimeSpan;
        case CustomFieldType.Flag:
              return attribute.FlagValue;
        case CustomFieldType.Text:
              return attribute.TextValue;
        case CustomFieldType.OutlineCode:
        case CustomFieldType.RBS:
        case CustomFieldType.Null:
        default:
              return null;
      }

The documentation should better reflect these answers.


#2

@JamesPike,

Thanks for contacting us. Can you please share working sample project, source file, generated output and desired output so that we may further investigate to help you out.


#3

Hello, presented below is the code that Aspose.Tasks uses in its sources:

 switch (attribute.AttributeDefinition.CfType)
  {
    case CustomFieldType.Cost:
    case CustomFieldType.Number:
          return (double)attribute.NumericValue;
    case CustomFieldType.Date:
    case CustomFieldType.Start:
    case CustomFieldType.Finish:
          return attribute.DateValue;
    case CustomFieldType.Duration:
          var dValue = attribute.DurationValue;
          return dValue.TimeSpan;
    case CustomFieldType.Flag:
          return attribute.FlagValue;
    case CustomFieldType.Text:
    case CustomFieldType.OutlineCode:
    case CustomFieldType.RBS:
          return attribute.TextValue;
    case CustomFieldType.Null:
          return null;
    default:
          return null;
  }

#4

I guess that is kind of my point. Why should I have to come up with all that?

If you are going to get rid of the .Value then there needs to be a more clear documentation of how to get the values. It’s clear that if I have a Number then NumberValue is probably the correct property, but OutlineCode and RBS are not intuitive. There should either be a OutlineCodeValue and RBSValue, or the API needs to have better documentation to tell us what value to get. I don’t think it should be up to me to blindly figure that out.

Also, a suggestion, but it would be nice if TextValue worked for all and just basically returned the ToString() of the value. Instead it errors if I try to get the TextValue of the Number (as an example).


#5

Thank you Alexander!


#6

@JamesPike,

Can we consider this thread closed.


#7

Yes. You can. Thank you for your help.


#8

@JamesPike,

Thank you for your feedback.