ExtendedAttribute FlagValue not evaluating formula


#1

We’re having a problem where we are trying to get the FlagValue of an ExtendedAttribute which is a Flag1-20 type on a task. If the value in the Project file is manually set it comes out fine as a true/false bool. However if the flag is set as the result of an expression, the formula doesn’t seem to evaluate and the resulting FlagValue is always false or null.

Am I doing something wrong here?

Screen shot of example project file
image.png (3.7 KB)

Console App result
Milestone where Number > 10 Number= 50 FlagValue = False Flag Formula = [Number1]>10
Milestone where Number < 10 Number= 1 FlagValue = null Flag Formula = [Number1]>10

Code snippet below with attached working example (minus the referenced licence file)

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var asm = Assembly.GetExecutingAssembly();
            using (var stream = asm.GetManifestResourceStream("ConsoleApp1.EmbeddedResources.Aspose.Total.lic"))
            {
                if (stream != null)
                {
                    Aspose.Tasks.License tasksLicense = new Aspose.Tasks.License();
                    tasksLicense.SetLicense(stream);
                }
            }



            using (Stream filesStream = GetExampleMpp())
            {
                Project project = new Project(filesStream);
                ExtendedAttributeDefinition flagAD = project.ExtendedAttributes.ToList().Find(a => a.FieldName.Equals("Flag1"));
                ExtendedAttributeDefinition numberAD = project.ExtendedAttributes.ToList().Find(a => a.FieldName.Equals("Number1"));

                foreach (var task in project.RootTask.Children)
                {
                    string name = task.Get(Tsk.Name);
                    var numberEA = task.ExtendedAttributes.FirstOrDefault(ea => ea.FieldId == numberAD.FieldId);
                    decimal number = numberEA.NumericValue;
                    var flagEA = task.ExtendedAttributes.FirstOrDefault(ea => ea.FieldId == flagAD.FieldId);
                    bool? flag = flagEA?.FlagValue;

                    Console.WriteLine($"{name} Number= {number} FlagValue = {(flag.HasValue ? flag.ToString() : "null" )} Flag Formula = {flagAD.Formula} ");
                }
                Console.ReadKey();

            }
        }

        private static Stream GetExampleMpp()
        {
            var asm = Assembly.GetExecutingAssembly();
            return asm.GetManifestResourceStream("ConsoleApp1.EmbeddedResources.Example.mpp");
        }

    }

ConsoleApp1.zip (8.5 MB)


#2

@sentientsoft,

I have worked with the sample file shared by you and have been able to observe the issue specified. An issue with ID TASKSNET-3497 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 fixed.