Hi,
Idea:
User provides a start date and a period (number of months). For each month, a record should be added to an SP list. I.e. start date = 1/1/2022; period = 3, I wish 3 records, namely for the following dates:
1) 1/1/2022 ...
2) 1/2/2022 ...
3) 1/3/2022 ...
I created a ClearCollect (ClearCollect(Loop, {Ind:0}, {Ind:1}, ...) in the OnStart of the App. Subsequently, on the OnSelect in the submit button I wrote:
Set(i, 0);
ForAll(
Filter(
Loop,
Ind <= Max(period),
Ind >= i
),
monthYear.SelectedDate = DateAdd(startDate.SelectedDate, Ind, Months);
SubmitForm(Form1)
)
This does not do anything (I also do not receive an error).
Hope someone can be of help 🙂
Solved! Go to Solution.
@rix0 ,
You have your ForAll backwards - it will work that way, but with significant performance penalties. Rather than "loop" individual data source writes, ForAll constructs a Table that can be written in one action
If(
IsBlank(ComboBox1.Selected),
Notify("Please Select a vendor"),
Patch(
'Vendor Rating',
ForAll(
Filter(
Loop,
Ind <= Max(DataCardValue13)
),
{
Title: DataCardValue15.Text,
StartDate: DataCardValue12.SelectedDate,
MonthYear: DateAdd(DataCardValue12.SelectedDate, Ind, Months)
}
)
)
)
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
Hi @rix0 ,
SubmitForm() will not do anything here - you need to Patch in this structure
With(
{
wMonth:
DateAdd(
startDate.SelectedDate,
Ind,
Month
)
},
Patch(
YourListName,
ForAll(
Filter(
Loop,
Ind <= Max(period) &&
Ind >= i &&
monthYear.SelectedDate = wMonth
} As aPatch,
{
Field1: aPatch.Field1,
Field2: aPatch.Field2,
Field13 aPatch.Field3,
. . . . . .
}
)
)
)
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
If(
IsBlank(ComboBox1.Selected),
Notify("Please Select a vendor"),
Set(i, 0)
//Notify(Max(DataCardValue13));
With(
{
wMonth:
DateAdd(
DataCardValue12.SelectedDate,
Ind,
Months
)
},
Patch(
'Vendor Rating',
ForAll(
Filter(
Loop,
Ind <= Max(DataCardValue13),
Ind >= i),
DataCardValue11.SelectedDate = wMonth
} As aPatch,
{
Title: aPatch.DataCardValue15.Selected.VendorID_Name,
StartDate: aPatch.DataCardValue12.SelectedDate,
...
}
)
)
)
)
First of all, thanks for the reply!
Sadly, this did not work for me.
@rix0 ,
I was assuming Ind is the number of months to be added - is it something else ? Also you are missing a semi-colon after Set(i,0)
I made some changes trying to get rid of the errors:
If(
IsBlank(ComboBox1.Selected),
Notify("Please Select a vendor"),
Collect(Records,
ForAll(
Filter(
Loop,
Ind <= Max(DataCardValue13),
DataCardValue11.SelectedDate = DateAdd(DataCardValue12.SelectedDate, Ind, Months)),
{
Title: DataCardValue15.Text,
StartDate: DataCardValue12.SelectedDate,
MonthYear: DataCardValue11.SelectedDate
}
)
)
);
Patch(
'Vendor Rating',
Records
)
however now it does not fill the sharepoint list (also I am not sure whether the Collection even gets filled this way)
The following seems to work for me,
If(
IsBlank(ComboBox1.Selected),
Notify("Please Select a vendor"),
ForAll(
Filter(
Loop,
Ind <= Max(DataCardValue13)),
Patch(
'Vendor Rating',
{
Title: DataCardValue15.Text,
StartDate: DataCardValue12.SelectedDate,
MonthYear: DateAdd(DataCardValue12.SelectedDate, Ind, Months)
}
)
)
)
Thanks for your help @WarrenBelz !
@rix0 ,
You have your ForAll backwards - it will work that way, but with significant performance penalties. Rather than "loop" individual data source writes, ForAll constructs a Table that can be written in one action
If(
IsBlank(ComboBox1.Selected),
Notify("Please Select a vendor"),
Patch(
'Vendor Rating',
ForAll(
Filter(
Loop,
Ind <= Max(DataCardValue13)
),
{
Title: DataCardValue15.Text,
StartDate: DataCardValue12.SelectedDate,
MonthYear: DateAdd(DataCardValue12.SelectedDate, Ind, Months)
}
)
)
)
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
User | Count |
---|---|
121 | |
88 | |
88 | |
75 | |
66 |
User | Count |
---|---|
215 | |
180 | |
138 | |
96 | |
82 |