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

Updateing DateTime Attribute with "HandleObjectComponent - Update"

Dear Community,

I needed to implement a process that sets a new "DateLastWorked" based on the ExitDate of a person.

The new DateLastWorked must be set to the end of the day, based on ExitDate, i.e. 09.10.2018 23:59:00.000

I chose the "HandleObjectComponent - Update" as process step.

I had a few problems implementing this easy function.

  1. It seems that the object layer doesn't correct the input-date to the correct database time (UTC).
    When I calculated the example value of "09.10.2018 23:59:00.000" it was written 1:1 to the database.
    Function to set the new variable:

          values("DateLastWorked") =  Person.GetValue("ExitDate").Date.Date.AddMinutes(-1).AddDays(1)

    That has, of course the effect that the wrong date is shown in the manager/web and the wrong date is transmitted to the target systems.
    What I then did was trying to calculate the utc time in the pre-script of the process.

  2. Sadly the function I used for that seems to be bugged in the context of a process (It works just fine in a custom script)

          values("DateLastWorked") =  DBVal.ToUniversalTime(Person.GetValue("ExitDate").Date.Date.AddMinutes(-1).AddDays(1),Connection.TimeZone)

    What works in an custom-script (Input 23:59 = 21:59 if local time is German time with daylight-saving "UTC+2") seems not to work in the context of a process.
    Input and output of that function are the same. 23:59 = 23:59.
    What works is that function that should work identical:

          values("DateLastWorked") =  Person.GetValue("ExitDate").Date.Date.AddMinutes(-1).AddDays(1).Add(-Connection.TimeZone.BaseUtcOffset)

Now I'm confused about the behavior and I have two questions:

  1. Is it correct that the object layer doesn't correct date values to the database time zone when using the "HandleObjectComponent - Update" process-component?
  2. Why are the two function calls have different results when they should do the same?

I have tested the behavior in 7.1.2 and 8.0.2 with same results.

Parents Reply
  • Mmhh.

    Where do you execute your sample code again?

    So where is this code placed?

    I checked the code and ToUniversalTime detects that the current datetime is UTC based (as said before, all dates are considered UTC based) and doesn't convert the value.

    This is true, regardless of the timezone setting used.

Children