Account Expires Warning

Hello,

Getting an issue with the account expires logic, this is only happening with a few employees. How can we resolve the win32 time error?


image

The reason it throws a Win32FileTime error is because you are adding 1 day to a null value.

Some employees do not have a DateLastWorked value (because they are still active in UKG) and their DateLastWorked value is null.

Which is why it only happens with some employees.

When you call the AddDays(1) method on a null it will result in a Win32FileTime error.

If you want to avoid this error, then will first need to check for a null DateLastWorked value, and only add 1 day if it is not null.

There are 2 ways to do this:

Use a C# ternary expression (which is similar to an immediate if)

(Employment.DateLastWorked != null)? Employment.DateLastWorked.GetValueOrDefault().AddDays(1): null

or

Use a conditional expression

WHEN
Employment.DateLastWorked != null
THEN
Employment.DateLastWorked.GetValueOrDefault().AddDays(1)

WHEN
Default
THEN
null