3 Replies Latest reply on Feb 6, 2018 7:08 PM by Wirepower

    Date Field (Text written as ddmmyy),now need to convert to dd/mm/yy to email button only.

    Wirepower

      Here is my attempted code:

       

      var Datebegin = util.scand("dd/mm/yy", this.getField("WeekBegin").valueAsString); // create date object using WeekNumber input
      var Dateend = util.scand("dd/mm/yy", this.getField("WeekEnd").valueAsString); // create date object using WeekEnd input

       

      var theSubject = this.getField("NAME").value +"'s week " + this.getField("WeekNumber").value + " Timesheet from " + this.getField("Datebegin").value + " To " +
      this.getField("Dateend").value 

      this.mailDoc({ 
        bUI: false, 
        cTo: this.getField("Email1").value, 
        cCc: this.getField("Email2").value, 
        cSubject: theSubject, 
        cMsg: "This is " + this.getField("NAME").value +"'s week " + this.getField("WeekNumber").value + " Timesheet from " + this.getField("Datebegin").value + " To " + this.getField("Dateend").value

      });

       

       

      However when I have the WeekBegin(ddmmyy) & WeekEnd(ddmmyy) fields filled in. Debugger gives me:

       

      TypeError: this.getField("Datebegin") is null

      TypeError: this.getField("Dateend") is null

      4:Field:Mouse Up

       

       

      Anyone help me on what I'm doing wrong?

        • 1. Re: Date Field (Text written as ddmmyy),now need to convert to dd/mm/yy to email button only.
          Wirepower Level 1

          2nd attempt with this code:

           

          var Datebegin = util.scand("ddmmyy", this.getField("WeekBegin").valueAsString); // create date object using WeekNumber input
          var Dateend = util.scand("ddmmyy", this.getField("WeekEnd").valueAsString); // create date object using WeekEnd input

          var theSubject = this.getField("NAME").value +"'s week " + this.getField("WeekNumber").value + " Timesheet from " + Datebegin + " To " +
          Dateend 

          this.mailDoc({ 
            bUI: false, 
            cTo: this.getField("Email1").value, 
            cCc: this.getField("Email2").value, 
            cSubject: theSubject, 
            cMsg: "This is " + this.getField("NAME").value +"'s week " + this.getField("WeekNumber").value + " Timesheet from " + Datebegin + " To " + Dateend

          });

          • 2. Re: Date Field (Text written as ddmmyy),now need to convert to dd/mm/yy to email button only.
            Wirepower Level 1

            ok sort of got it, but now on the email its giving me a long time stamp, all I want is dd/mm/yy or dddd mmmm yyyy.

            How can I amend my coding above to do this layout?

            • 3. Re: Date Field (Text written as ddmmyy),now need to convert to dd/mm/yy to email button only.
              Wirepower Level 1

              all good got it working..

              Here is the working code:

               

              var Datebegin = util.scand("ddmmyy", this.getField("WeekBegin").valueAsString); // create date object using WeekNumber input
              var Dateend = util.scand("ddmmyy", this.getField("WeekEnd").valueAsString); // create date object using WeekEnd input

              var theSubject = this.getField("NAME").value +"'s week " + this.getField("WeekNumber").value + " Timesheet from " + util.printd("dd/mm/yyyy", Datebegin) + " To " +
              util.printd("dd/mm/yyyy", Dateend)

              this.mailDoc({ 
                bUI: false, 
                cTo: this.getField("Email1").value, 
                cCc: this.getField("Email2").value, 
                cSubject: theSubject, 
                cMsg: "This is " + this.getField("NAME").value +"'s week " + this.getField("WeekNumber").value + " Timesheet from " + util.printd("dd/mm/yyyy", Datebegin) + " To " + util.printd("dd/mm/yyyy", Dateend)

              });