The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Are IsNull vs IsUninitialized possibly true after successful TryGetProperty?

Using VAF, I want to assess the values of two Date Properties in a state trigger.

First I check to see if the Property is on the Object using the TryGetProperty method, since if there is no required date property on the object we know this is going to fail. But then I wasn't sure if TryGetProperty would succeed if the property is on the object but has no value (IsNull should then be true). I don't think it is possible for IsUninitialized to be true as that would only be the case if the SetValue had never been invoked, but I am assuming that the GetProperty, when it succeeds constructs the TypedValue even if it is Null.

I'm trying to make sure I don't blow up when I try to cast the Value to a DateTime to see if I've passed the required date.

if (!env.PropertyValues.TryGetProperty(PDAssessmentDateID, out PropertyValue assessmentDate))
{
    return false;
}

//I think the previous checks would catch these but not sure
if(assessmentDate.TypedValue.IsNULL() || assessmentDate.TypedValue.IsUninitialized())
{
    return false;
}

bool timeToAssess = (DateTime.Now.Subtract((DateTime)assessmentDate.Value.Value).TotalDays > 0);

return timeToAssess;