How to work with date fields

Home Forums Modern DFFS How to work with date fields

Viewing 3 reply threads
  • Author
    Posts
    • #39193
      Wim Stevens
      Participant

        We upgraded to modern dffs. There is Javascript code that reads a date/time field, adds some hours to it and stores the result in another field.
        The old Javascript was not upgraded automatically.

        I tried
        x = getFieldValue(“InfoSecuritySetDate”);
        x.setHours(x.getHours() + maxDelayHours);
        setFieldValue(“Due_x0020_Date”, x);

        This does not work because x is a String and not a Date object.
        Question: how to retrieve the Date object that corresponds to InfoSecuritySetDate ? I have no idea what regional settings are used by the user. I cannot make assumptions about the regional settings of the Sharepoint site

        Remark 1: the functions getFieldValue and setFieldValue are not documented in the user guide. I have found the functions via AI. Maybe there are other functions available that could be used.

        Thanks

        Regards

      • #39194
        Alexander Bautz
        Keymaster

          The only missing piece here is to specify the format of the value returned by the getFieldValue call – if you write it like this it gives you a proper date object:

          x = getFieldValue("InfoSecuritySetDate", "object");
          

          Alexander

        • #39195
          Wim Stevens
          Participant

            Excellent. This is what I needed.
            Have I missed it in the documentation ?

            Wim

          • #39196
            Alexander Bautz
            Keymaster

              This is currently not documented but the next version of Modern DFFS will have an autocomplete / info text when you start typing in the Custom JS textarea to show the different options available.

              Alexander

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