datetime field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • peterberlin
    Active Community Member
    • Mar 2015
    • 1004

    datetime field

    Hi,
    in a separate entity we have two datetime fields "beginning" and "end". Users select the contents of the beginning field and must also select the day and time in the end field.
    Is it possible to organize that the day of the field end is the day of the field beginning.
    Also, it would be very good if you don't have to scroll from 0:00 at all times.
    peter
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hi,
    you can override tho view for your field "beginning", or you can add a field "duration" and "end" field will be calculated on the form, like in Meeting and Call entity?
    What is the name of your entity, and what way is good for you?

    Comment

    • peterberlin
      Active Community Member
      • Mar 2015
      • 1004

      #3
      Hi Tanya,
      Thanks for your suggestions.
      We have created our own modules in which we record times. I have already used the idea of calculating the end time using duration.
      The determination of the duration in the person works it ouit in his head miscalculations.
      The problem of scrolling from 00:00 to a time is complex in each module.
      peter

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        Hi Peter,
        the easiest way is to set default in Entity Manager. It will set curent time as default an autoscroll to current time value.
        If you want to set in the file client/src/views/fields/datetime.js setDefaultTime - change the time value. (from 00:00 to 11:00 for example). You can change the view for all datetime field or only for needed.

        Comment


        • huscmk
          huscmk commented
          Editing a comment
          Hi,
          Is there a way to modify this function in an upgrade safe way ?

          Thanks
      • peterberlin
        Active Community Member
        • Mar 2015
        • 1004

        #5
        I've learned something new. Thank you very much Tanya

        Comment

        • peterberlin
          Active Community Member
          • Mar 2015
          • 1004

          #6
          Can you give me an example? :

          setDefaultTime: function () {
          var d = moment('2014-01-01 00:00').format(this.getDateTime().getDateTimeForma t()) || '';
          var index = d.indexOf(' ');
          if (~index) {
          this.$time.val(d.substr(index + 1));
          }
          },

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #7
            I tested with

            setDefaultTime: function () {
            var d = moment('2014-01-01 11:00').format(this.getDateTime().getDateTimeForma t()) || '';
            var index = d.indexOf(' ');
            if (~index) {
            this.$time.val(d.substr(index + 1));
            }
            },

            Comment

            • peterberlin
              Active Community Member
              • Mar 2015
              • 1004

              #8
              I changed the file. Scrolling starts at 00:00 am.

              Comment

              • tanya
                Senior Member
                • Jun 2014
                • 4308

                #9
                After clear local cache, refreshing page and for new record without the default value?

                Comment

                • peterberlin
                  Active Community Member
                  • Mar 2015
                  • 1004

                  #10
                  've done everything. No success.

                  Comment

                  • tanya
                    Senior Member
                    • Jun 2014
                    • 4308

                    #11
                    For me it works. Could you share more information about the field?
                    - the entity (if not custom)
                    - field Defs (/Resorses/enitityDefs/{EntityName}.json -> fields -> {field} content)

                    Comment

                    • peterberlin
                      Active Community Member
                      • Mar 2015
                      • 1004

                      #12
                      it works for Meetings. with your own entity it doesn't work

                      "anfang": {
                      "notNull": false,
                      "type": "datetime",
                      "required": false,
                      "isCustom": true,
                      "default": null,
                      "audited": false,
                      "readOnly": false,
                      "tooltip": false
                      },

                      Comment

                      • tanya
                        Senior Member
                        • Jun 2014
                        • 4308

                        #13
                        it works for custom entity and custom field as well

                        Comment

                        • peterberlin
                          Active Community Member
                          • Mar 2015
                          • 1004

                          #14
                          I have looked again at the fields of the entity meetinmg. (see attachment) This is probably the reason why it works with this entity.
                          Unfortunately I can't insert this script into the other file types. There's a selection menu.

                          Comment

                          • tanya
                            Senior Member
                            • Jun 2014
                            • 4308

                            #15
                            )) https://forum.espocrm.com/forum/general/25255-event

                            Originally posted by peterberlin

                            "anfang": {
                            "notNull": false,
                            "type": "datetime",
                            "required": false,
                            "isCustom": true,
                            "default": null,
                            "audited": false,
                            "readOnly": false,
                            "tooltip": false
                            },
                            as you can see, you have the "default" option. Copy this row here
                            "default": "javascript: return this.dateTime.getNowMoment().hours(8).minutes(0).u tc().format(this.dateTime.internalDateTimeFormat); ",

                            The method I wrote before (client/src/views/fields/datetime.js setDefaultTime) is for all datetime field, which doesn't have the default value. This method (with default) affects only for this field.

                            Comment

                            Working...