Hello all,
I've run into an issue that I can't seem to get around.
ForAll(
Set(Counter, 1);
FirstN(
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30],
CountRows(SelectedPersonel)),
Patch(<DATA_SOURCE>, Defaults(<DATA_SOURCE>),
{
BriefHeader: DataCardValue5.Text,
BriefOn: DatePicker1.SelectedDate,
Item1:DataCardValue18.Text,
User: Concat(FirstN(LastN(SelectedPersonel, Counter)), Name)
}
)
);
Set(Counter, Counter +1);
What this does is creates a new SharePoint list entry, with 1 changing field "User". I have it all working apart from getting the "Counter" to increment by 1, I need the Counter to go from 1>2>3>4 for each time a SharePoint List item is created (What this does is create a list item that is identical, apart from the user which will change).
When I manually put an integer instead of the Counter it all works perfectly, so typing in 1..then 2... Obviously I want this to be automated!
Where do I need to slot in Set(Counter, Counter +1); ? I've tried but it throws an error for using Set() in a ForAll
Thanks in advance!
Solved! Go to Solution.
In Power Apps, a ForAll is more like a table operation than a looping function. Let the ForAll do the counting for you by feeding it the table of data you want to operate on. For example, if you have a table with a column of names try this:
ForAll(Personel,
Patch(<DATA_SOURCE>,Defaults(<DATA_SOURCE>),
{
BriefHeader: DataCardValue5.Text,
User: ThisRecord.Name
// And so on
}
)
)
Does that fit with what you are trying to do?
Bryan
In Power Apps, a ForAll is more like a table operation than a looping function. Let the ForAll do the counting for you by feeding it the table of data you want to operate on. For example, if you have a table with a column of names try this:
ForAll(Personel,
Patch(<DATA_SOURCE>,Defaults(<DATA_SOURCE>),
{
BriefHeader: DataCardValue5.Text,
User: ThisRecord.Name
// And so on
}
)
)
Does that fit with what you are trying to do?
Bryan
This is perfect! Thank you. Thinking about it this way and using the ForAll to do the counting is a perfect solution that is also much simpler
User | Count |
---|---|
256 | |
114 | |
95 | |
48 | |
40 |