Hi guys,
I have built an app for my company that essentially works as a lunch ordering app, in which my coworkers and I can order our lunch in the cantina, and the information about this will then automatically be sent to our HR lead that deals with salaries so she knows how much to charge us each month.
Right now the app functions in such a way that one can order for the entire present week. However, lately colleagues have been requesting to up this to two weeks. This is where i need your help or inputs. As seen below this is how it works at the moment, where you are able to order monday through friday. My biggest concern with having to up this to two weeks, is the lack of understandings dates that PowerApps have. and right now to close orders for the day i am using this code:
If(Or(Weekday(Today();Monday)>3;
And(Weekday(Today();Monday)=3;TimeValue(Text(Now()))>Time(09;30;00)));Disabled;DisplayMode.Edit)
As you can see i am using the numbers 1-7 to close the orders at 09:30 at a specific date, in the case above on wednesdays as Monday is the first day of the week here.
The way it gathers data right now, is that the app patches to a SP list, and a flow then grabs the data from each day, where each day have specific list. The data is then inserted into an excel sheets which is sent off to the salary lady on the 15th of every month.
Do any of you have a clever ideas on how to possibly extend something like this to two weeks?
- Tobi
Solved! Go to Solution.
Hi @Anonymous ,
Do you patch the selected items (with Checkbox checked) from your Gallery back to your SP List?
If you want to patch the selected items (with Checkbox checked) from your Gallery back to your SP List, I think the combination of ForAll function and Patch function could achieve your needs.
You could consider add a "Submit" button outside the Gallery, then set the OnSelect property to following formula:
ForAll(
Filter(Gallery1.AllItems, Checkbox1.Value = true),
Patch(
'YourSPList',
Defaults('YourSPList'),
{
Title: "Data Entry",
OrderUser: User().DisplayName,
OrderDate: Value, // Value represents the column property from the Gallery
...
}
)
)
Note: The OrderUser, OrderDate, ... represents the columns in your SP list. The OrderUser column is used to store the user who submits order request. OrderDate column is used to store the date value when the user want to order.
More details about patch Gallery items back to SP List, please check and see if the following thread would help in your scenario:
Best regards,
Hi @Anonymous ,
Could you please share a bit more about your scenario?
Do you want to apply the "Close Orders" functionality to two weeks?
Based on the needs that you mentioned, I think the Gallery control could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:
Set the OnStart property of App to following:
Clear(DateRanges);
ForAll( // collect the date ranges from this Monday to next Sunday
FirstN([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14], DateDiff(DateAdd(Today(), -Weekday(Today(), Monday)+1),DateAdd(Today(), -Weekday(Today(), Monday)+14))+1),
Collect(DateRanges, DateAdd(DateAdd(Today(), -Weekday(Today(), Monday)+1), Value))
)
Add a Gallery, set the Items property to following:
DateRanges
add a Checkbox within above Gallery, set the Text property to following:
Switch(
Weekday(ThisItem.Value, Monday),
1, "Monday",
2, "Tuesday",
3, "Wednesday",
4,"Thursday",
5, "Friday",
6, "Saturday",
7, "Sunday"
) & "-" & ThisItem.Value
set the DisplayMode property of the Checkbox to following:
If(
Or(
Weekday(ThisItem.Value, Monday)>3,
And(Weekday(ThisItem.Value, Monday)=3, TimeValue(Text(Now()))>Time(09,30,00))
),
DisplayMode.Disabled,
DisplayMode.Edit
)
Within above Gallery, it list two week dates, from this Monday to next Sunday.
Please check the attached sample app for more details. Please take a try with above solution, check if the issue is solved.
Best regards,
@v-xida-msft
Yes, this does work, in terms of the design and interface. and thats great.
The Displaymode seems to be a bit off, but that i can figure out from the already build app.
But I think where i am really in a headache is with the "Backend" so the data manipulation. And finding out a way of making in so that it patches to a list in SharePoint in a smart way, so that it creates a list for each Unique day, if that makes sense? 😉
- Tobi
Hi @Anonymous ,
Do you patch the selected items (with Checkbox checked) from your Gallery back to your SP List?
If you want to patch the selected items (with Checkbox checked) from your Gallery back to your SP List, I think the combination of ForAll function and Patch function could achieve your needs.
You could consider add a "Submit" button outside the Gallery, then set the OnSelect property to following formula:
ForAll(
Filter(Gallery1.AllItems, Checkbox1.Value = true),
Patch(
'YourSPList',
Defaults('YourSPList'),
{
Title: "Data Entry",
OrderUser: User().DisplayName,
OrderDate: Value, // Value represents the column property from the Gallery
...
}
)
)
Note: The OrderUser, OrderDate, ... represents the columns in your SP list. The OrderUser column is used to store the user who submits order request. OrderDate column is used to store the date value when the user want to order.
More details about patch Gallery items back to SP List, please check and see if the following thread would help in your scenario:
Best regards,
User | Count |
---|---|
256 | |
254 | |
82 | |
41 | |
30 |
User | Count |
---|---|
319 | |
269 | |
121 | |
68 | |
50 |