Idea for SetFieldValue for datetime columns

Home Forums Modern DFFS Idea for SetFieldValue for datetime columns

Viewing 2 reply threads
  • Author
    Posts
    • #36878
      Travis Goodman
      Participant

        Hi Alexander, this idea would be for both modern and classic DFFS. I’m noticing that SetFieldValue for DateTime columns will set the time portion of the date field to the users local time zone rather than the time zone set by the regional settings of the site collection. I need all information entered as a specific time zone, is there any way to enforce that functionality?

        Example, the site collection is set to Central Time and it’s 3pm right now. I had a user in Pacific Time which is 2 hours behind Central Time so the SetFieldValue rule set the timestamp for 1pm instead of 3pm.

        Thoughts?

      • #36879
        Travis Goodman
        Participant

          For reference, this was being done when I had a rule to set the date field value to [today]#now

        • #36889
          Alexander Bautz
          Keymaster

            You can try setting it like this:
            Classic DFFS:

            let d = new Date();
            console.log("Client date:", d);
            d.setHours(d.getHours()-(_spPageContextInfo.webTimeZoneData.Bias - _spPageContextInfo.webTimeZoneData.DaylightBias) / 60);
            console.log("Server date:", d);
            spjs.utility.setDateFieldFromDateObject("DateColumn",d);
            

            Modern DFFS

            let d = new Date();
            console.log("Client date:", d);
            d.setHours(d.getHours()-(_spPageContextInfo.webTimeZoneData.Bias - _spPageContextInfo.webTimeZoneData.DaylightBias) / 60);
            console.log("Server date:", d);
            setFieldValue("DateColumn",d);
            

            Please note that I’m not 100% sure I have the calculation of the “Bias” correct – you might have to change from – to + but you can look at it and see if it makes sense.

            Alexander

        Viewing 2 reply threads
        • You must be logged in to reply to this topic.