Maciek Grischke

Forum Replies Created

Viewing 15 posts - 16 through 30 (of 55 total)
  • Author
    Posts
  • in reply to: Setting field value rule for Date/Time field tyoe #25619
    Maciek Grischke
    Participant

      I couldn’t get the date format “01/06/2019 11:00” to do what I wanted it to do hence all the extra steps.

      Thanks for the one line solution 😛

      in reply to: Setting field value rule for Date/Time field tyoe #25604
      Maciek Grischke
      Participant

        I got this working:

        //get Day End Date and Time
        function getEndDate() {
         var endDate = getFieldValue("EndDate");
         var endDate2 = endDate.split("/");
         var endDate3 = endDate2[1] + "/" + endDate2[0] + "/" +endDate2[2];
         var MyEndDate = endDate3.split(" ");
         var Time = MyEndDate[1];
         var MyEndDate2 = MyEndDate[0];
         var MyEndDate3 = MyEndDate2.split("/");
         var MyEndDate4 = MyEndDate3[2]+"-"+MyEndDate3[0]+"-"+MyEndDate3[1]+"T"+Time+"Z";
         var MyEndDate5 = new Date(MyEndDate4);
         MyEndDate5.setHours(MyEndDate5.getHours() - 1);
         spjs.utility.setDateFieldFromDateObject("SleepStart",MyEndDate5,0);
        // alert(MyDate5);
        }
        
        //get Day Start Date and Time
        function getStartDate() {
         var startDate = getFieldValue("StartDate");
         var startDate2 = startDate.split("/");
         var startDate3 = startDate2[1] + "/" + startDate2[0] + "/" +startDate2[2];
         var MyStartDate = startDate3.split(" ");
         var Time = MyStartDate[1];
         var MyStartDate2 = MyStartDate[0];
         var MyStartDate3 = MyStartDate2.split("/");
         var MyStartDate4 = MyStartDate3[2]+"-"+MyStartDate3[0]+"-"+MyStartDate3[1]+"T"+Time+"Z";
         var MyStartDate5 = new Date(MyStartDate4);
         MyStartDate5.setHours(MyStartDate5.getHours() - 1);
         spjs.utility.setDateFieldFromDateObject("SleepEnd",MyStartDate5,1);
        // alert(MyDate5);
        }
        

        I probably don’t need all of the date/time conversion.
        What do you think? 🙂

        in reply to: Setting field value rule for Date/Time field tyoe #25600
        Maciek Grischke
        Participant

          Hi Alexander,

          The day and night shifts are different for different people.

          7:30/22:00 was just an example.

          What I meant was, if the employee selects a ‘time in’ 9:00 and ‘time out’ 20:00 for a day shift, the same time (in this case 20:00-9:00) is copied to the night shift (if “night” option is set to “yes”) to make it easier for users.

          Please note, the second date for the night shift would be +1 day.

          in reply to: Setting field value rule for Date/Time field tyoe #25593
          Maciek Grischke
          Participant

            Hi Alexander,

            How can I use the above to set dates from an existing date field?

            I have 4 date fields and here’s what I want to do. Select shift start and end manually:

            Day:
            StartDate: 01/06/2019 7:30
            EndDate: 01/06/2019 22:00

            and then if option “night” is selected, fill in the following dates automatically:

            Night:
            NightStartDate 01/06/2019 22:00
            NightEndDate 02/06/2019 7:30 (next day)

            in reply to: Calculate time difference in hours or minutes #25591
            Maciek Grischke
            Participant

              Thanks Alexander, this works great in standard lists, but not calendar.

              I get “invalid date” and NaN as the result.

              Dates in Calendar are set as Event columns. Not sure what the difference is, because the calculated column can calculate dates no problem.

              in reply to: Calculate time difference in hours or minutes #25579
              Maciek Grischke
              Participant

                Ok, I found a way to do this, but maybe there’s a better way?

                var startDate = "03/06/2019 20:15";
                var endDate = "03/06/2019 22:00";
                //console.log("startDate");
                //console.log(startDate);
                var startDate2 = startDate.split("/");
                var endDate2 = endDate.split("/");
                var startDate3 = startDate2[1] + "/" + startDate2[0] + "/" +startDate2[2];
                var endDate3 = endDate2[1] + "/" + endDate2[0] + "/" +endDate2[2];
                //console.log("startDate3");
                //console.log(startDate3);
                var startDate4 = new Date(startDate3);
                var endDate4 = new Date(endDate3);
                //console.log("startDate4");
                //console.log(Date.parse(startDate4));
                //console.log("endDate");
                //console.log(Date.parse(endDate4));
                var calc = (endDate4 - startDate4)/1000/60/60;
                console.log(calc);
                

                I just need help getting this to work in NewForm when Date and Time is selected 😉
                I’d like to enter the total hours in “Total” field.

                in reply to: DFFS sum multiple fields in a totals field #25501
                Maciek Grischke
                Participant

                  Hi Alexander,

                  I replicated the issue in my test site. I added the log to the code, but the log (or the code) is not triggering until I delete one of the numbers with an X icon. X icon at the end of the field. Deleting the number with a backspace or delete keys is not doing anything. Weird.
                  The X icon seems to be only available in Edge, I don’t see it in any other browser.

                  Also, the calculation only works when I click away from the number field, not on “keyup” – this applies to all browsers, but that’s not an issue.

                  Please note, the “Total” field is a text field, but I just changed it to a number field and the same behaviour occurs.

                  The list in my test site is called CalcTest

                  /CalcTest/AllItems.aspx
                  
                  in reply to: Trigger spell check #25481
                  Maciek Grischke
                  Participant

                    I used this code to enable browser’s spell checker on all text fields. For some reason, it’s disabled on SharePoint…

                    $(document).ready( function() {
                        $("input[type='text'], textarea").attr('spellcheck',true);
                    });
                    
                    in reply to: DFFS sum multiple fields in a totals field #25324
                    Maciek Grischke
                    Participant

                      Hi again,

                      I just noticed that the calculation does not work in Edge. Whether it’s read only or editable.

                      Any idea why and do you think it’s fixable?

                      It works fine in Forefox, Chrome, IE and even Opera, but not Edge and we know Edge is now being forced on users so I’m worried I will be getting complaints at some point.

                      in reply to: DFFS sum multiple fields in a totals field #25228
                      Maciek Grischke
                      Participant

                        Thanks! This worked great as usual 🙂

                        in reply to: Calculation in rules #25225
                        Maciek Grischke
                        Participant

                          Alexander,

                          Time in UK format is 06/05/2019 (with forward slash) and this is how it’s displayed in lists etc, however, users can enter this date as 06.05.2019 and SharePoint will accept it no problem. Unfortunately, when used with DFFS and the above snippet, there is no warning. The warning only works with 06/05/2019 date format.

                          Hope this makes sense.

                          Thanks.

                          in reply to: DFFS sum multiple fields in a totals field #25202
                          Maciek Grischke
                          Participant

                            Hi guys,

                            is it possible to make the Total field read-only?

                            in reply to: Calculation in rules #25200
                            Maciek Grischke
                            Participant

                              Alexander, since sharepoint accepts dates in dd.MM.yyyy format (full stop) and we have users who use dots, the rule above doesn’t seem to be working in this case.

                              Do I have to use JS replace() to each field or is there another way of doing this?

                              My region is set to UK.

                              Thanks.

                              in reply to: Number field validation to use dot and not comma #25197
                              Maciek Grischke
                              Participant

                                Ok, I found a way to do this. Actually, a few ways, but which one is more appropriate or correct or are all of them correct?

                                jQuery("#dffs_Title input").on("keyup",function(e){
                                    var str = jQuery(this).val();
                                    jQuery(this).val(str.replace(/[^0-9.]/g, ''));
                                });
                                

                                or

                                jQuery("#dffs_Title input").on("keyup",function(e){
                                    var str = jQuery(this).val();
                                    jQuery(this).val(str.replace(/[^\d.-]/g, ''));
                                });
                                

                                both work and do what I need them to do, but what’s the difference?

                                in reply to: Number field validation to use dot and not comma #25193
                                Maciek Grischke
                                Participant

                                  Thanks Alexander.

                                  Unfortunately, this is a text field and users can enter anything in there. Is there a way to replace any other character than a number with ‘no space’?

                                  I have a Flow built for this form and I’d like to avoid redoing the Flow, if possible.

                                Viewing 15 posts - 16 through 30 (of 55 total)