Forum Discussion

Jeff_Lacarte's avatar
Jeff_Lacarte
Brass Contributor
Nov 09, 2021

PowerApps Form Default Date as Selected Date from Calendar View

Hi everyone, I'm hoping to figure out if this is possible or not.

 

I have a list in sharepoint with a start and end date. I've added the Calendar view to the list, which works great. I've integrated a PowerApps app as the new/edit forms for items in the list. Here is my scenario, the default behaviour while in calendar view is that you can select the "+ New" link on any given calendar date and have that date show up as the start date in the default SharePoint new item form. As mentioned, I've integrated a PowerApps for custom form behaviour. I cannot figure out a way to use the date the user selects from calendar view as the default date in a date field of the form.

 

Knowing that PowerApps are data driven I'm guessing there isn't a way to achieve this? Here is a picture that helps better explain what I am trying to do:

  • rnibclc's avatar
    rnibclc
    Copper Contributor
    What a disappointment. This seems like an easy ask for Microsoft. Not sure why so difficult. I am glad you posted and sad there is no solution!
  • JDeAraujo's avatar
    JDeAraujo
    Copper Contributor
    Sorry to bump an old discussion, but I've had success by referring to the SharePointIntegration object to get the Selected item.

    SharePointIntegration.Selected.'Draft due by'

    ...where 'Draft due by' is the field name of the current item.
    • Gislele's avatar
      Gislele
      Copper Contributor

      Hey JDeAraujo are you applying this SharePointIntegration.Selected object in the card Default property?

       

      Like this:


      I've tried it, but still no success

      • cwalkerlb21's avatar
        cwalkerlb21
        Copper Contributor

        Gislele I am trying to use your suggestion of sharepointintegration.selected.'start date' but I am having trouble figuring out where you put this. Was it under the defaultdate for the datepicker datacard or was it somewhere else? Thanks for figuring this out and look forward to hearing more!

    • cwalkerlb21's avatar
      cwalkerlb21
      Copper Contributor

      JDeAraujo I am trying to use your suggestion of sharepointintegration.selected.'start date' but I am having trouble figuring out where you put this. Was it under the defaultdate for the datepicker datacard or was it somewhere else? Thanks for figuring this out and look forward to hearing more!

  • GaboX's avatar
    GaboX
    Copper Contributor
    I have the exact same question, and I see you're working in the exact same project I am for my Companies team.
    Although I have not the answer to your question (as I'm running into the same problem) I'd like to know: How did you setup the "All Day" toggle, more exactly which values did you fill the time combo fields when triggered?
    • Jeff_Lacarte's avatar
      Jeff_Lacarte
      Brass Contributor

      GaboX I've come at this a few different ways so far. My current approach involves hiding the hour and minute dropdowns when "all day" is toggled 'on'. Then on the data card for the start and end date fields I use an if within the "update" field. I like this approach since I don't have to track what the user had selected as a start/end time in the case of the user deciding they didn't want all day after all (since changing the values in the actual dropdowns would mean when the fields are visible again they would be set to 00:00 and 23:59 respectively). This way if the user toggles off All Day then they just see their originally selected values (which would be what is submitted).

       

      Note: DataCardValue2 is my Toggle control.

       

      Start date:  if all day then submit the selected date component only, otherwise submit selected date and time.

       

       

      If(DataCardValue2.Value,
          DateValue1.SelectedDate,
          DateValue1.SelectedDate
          + Time(
              Value(HourValue1.Selected.Value),
              Value(MinuteValue1.Selected.Value), 0
          )
      )

       

       

      End dateif all day then submit the selected date with the time set to 23:59, otherwise submit selected date and time.

       

       

      If(DataCardValue2.Value,
          DateValue2.SelectedDate
          + Time(23, 59, 0),
          DateValue2.SelectedDate
          + Time(
              Value(HourValue2.Selected.Value),
              Value(MinuteValue2.Selected.Value), 0
          )
      )

       

       

      Sorry for the long winded response. I tend to overexplain.

      • GaboX's avatar
        GaboX
        Copper Contributor

        Thanks, Jeff_Lacarte. That's close to what I did too, although what I updated was the hour dropdowns instead of the Start and End datacards (00:00 to start and 23:59 to end when the toggle is on).

        What I didn't like with the whole time selection idea though is that the hours and mins. are in separate dropdowns. Since this is for an absence tracker, I don't really need all the hours and all the mins, at least in our case. It's more like half-hour intervals. Also, when requesting time off in a normal schedule, that'd mean 6:00-18:00 max.

        So what I did was change the Hour dropdown Items values to half-hour intervals: 

         

        (DataCardValue9 is my "All day Toggle)

         

        Start

         

        If(DataCardValue9.Value;
        ["00:00"];
        ["06:00";"06:30";"07:00";"07:30";
        "08:00";"08:30";"09:00";"09:30";
        "10:00";"10:30";"11:00";"11:30";
        "12:00";"12:30";"13:00";"13:30";
        "14:00";"14:30";"15:00";"15:30";
        "16:00";"16:30";"17:00";"17:30";
        "18:00"])

         

        End

        If(DataCardValue9.Value;
        ["23:59"];
        ["06:00";"06:30";"07:00";"07:30";"08:00";
        "08:30";"09:00";"09:30";"10:00";"10:30";
        "11:00";"11:30";"12:00";"12:30";"13:00";
        "13:30";"14:00";"14:30";"15:00";"15:30";
        "16:00";"16:30";"17:00";"17:30";"18:00"])

         

        That way I could do this in the Hour Default value:


        Start

        If(DataCardValue9.Value;
        "00:00";
        Text((Parent.Default)
        ;DateTimeFormat.ShortTime24))

        End

        If(DataCardValue9.Value;
        "23:59";
        Text((Parent.Default);DateTimeFormat.ShortTime24))

         

        I also got rid of the Mins. dropdown and change the Start and End datacards' update value to:

        Start

        DateValue1.SelectedDate 
        + Time(Value(Left(HourValue1.Selected.Value;2)); 
        Value(Right(HourValue1.Selected.Value;2)); 0)

         

        End

        DateValue2.SelectedDate 
        + Time(Value(Left(HourValue2.Selected.Value;2));
        Value(Right(HourValue2.Selected.Value;2)); 0)

         

        In the end, it looks something like this:

         

        I decided not to hide the time dropdown when the toggle was on, so it looks like this when it's selected:

         

         

        I guess I tend to overexplain too :smile:

  • Jeff_Lacarte I am not sure if this is possible using Power Apps customized form. But, I can see that this behavior is already available in SharePoint default form for date field which is selected as Start date on calendar in calendar view settings.

    Output:


    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    • Jeff_Lacarte's avatar
      Jeff_Lacarte
      Brass Contributor
      Yes! That's what made me want it in the PowerApps form; the fact that it works in the default view. I really like that functionality of the default new form, however I do not like the time picker since there is no way to do an "all day" toggle that sets the time to beginning and end of day.

Resources