cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jayant_2203
Helper II
Helper II

Create SharePoint record for date range and days

Hi All,

I have a very specific requirement that is related to creation of records in a SharePoint list.
Requirement

The form would allow the user to select a start date and an end date. Now the user will also have an option to select Days of Week. For Example: Monday, Tuesday , Wednesday and so on.

Now if the user selects a date range from 01/11/2021 - 07/11/2021 and selects the days as Monday , Wednesday and Friday. Then, the system should create 3 identical records only for those dates which fall on these days as selected by user.

i hope i am making sense. How can this be done in PowerApps?

Any help would be appreciated.

Thanks in advance!

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @Jayant_2203 ,

I felt like a challenge on this one so please look at this carefully as it works in my model

WarrenBelz_0-1635846462382.png

Date Pickers are dpStart and dpEnd

Combo Box is cbDays with Multiple Selection and the Items

[
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
]

Button OnSelect

Clear(colDays);
With(
   {
      wStart: dpStart.SelectedDate,
      wEnd: dpEnd.SelectedDate
   },
   ForAll(
      Sequence(
         DateDiff(
            wStart,
            wEnd,
            Days
         ) + 1
      ),
      With(
         {
            wDay:
            DateAdd(
               wStart,
               Value - 1,
               Days
            )
         },
         If(
            Text(
               wDay,
               "ddd"
            ) in cbDays.SelectedItems,
            Collect(
               colDays,
               {WeekDay: wDay}
            )
         )
      )
   )
)

The gallery is simply Items

colDays

and the label Text

Text(ThisItem.WeekDay,"dddd, d mmmm yyyy")

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

@Jayant_2203 ,

What exactly do you mean by that? What will the records contain and where are you getting the data from for the identical records. You would only have to add the fields here (also do not use Date as a field name)

Collect(
   colDays,
   {
      DateValue: wDay,
      Title:"YourTitleValue",
      OtherField:"YourOtherValue"
   }
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

View solution in original post

5 REPLIES 5
Ramole
Super User
Super User

Hi @Jayant_2203 

 

Have a look this post https://powerusers.microsoft.com/t5/Building-Power-Apps/Splitting-date-range-to-different-Sharepoint... 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.
WarrenBelz
Super User
Super User

Hi @Jayant_2203 ,

I felt like a challenge on this one so please look at this carefully as it works in my model

WarrenBelz_0-1635846462382.png

Date Pickers are dpStart and dpEnd

Combo Box is cbDays with Multiple Selection and the Items

[
    "Mon",
    "Tue",
    "Wed",
    "Thu",
    "Fri",
    "Sat",
    "Sun"
]

Button OnSelect

Clear(colDays);
With(
   {
      wStart: dpStart.SelectedDate,
      wEnd: dpEnd.SelectedDate
   },
   ForAll(
      Sequence(
         DateDiff(
            wStart,
            wEnd,
            Days
         ) + 1
      ),
      With(
         {
            wDay:
            DateAdd(
               wStart,
               Value - 1,
               Days
            )
         },
         If(
            Text(
               wDay,
               "ddd"
            ) in cbDays.SelectedItems,
            Collect(
               colDays,
               {WeekDay: wDay}
            )
         )
      )
   )
)

The gallery is simply Items

colDays

and the label Text

Text(ThisItem.WeekDay,"dddd, d mmmm yyyy")

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Jayant_2203
Helper II
Helper II

@Ramole Thanks for the reference. I wanted to create SharePoint records for date range for selected days.

@WarrenBelz thank you for the answer. 
However, i would want to create SharePoint records for Tuesday , Thursday and Sunday. between the selected date range. 
How can i do so?

SharePoint List item can be basic details like Title , Date , etc..

@Jayant_2203 ,

What exactly do you mean by that? What will the records contain and where are you getting the data from for the identical records. You would only have to add the fields here (also do not use Date as a field name)

Collect(
   colDays,
   {
      DateValue: wDay,
      Title:"YourTitleValue",
      OtherField:"YourOtherValue"
   }
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,770)