Reputation: 2742
I'm trying to insert a range of serial numbers into the SQL Server table.
I'm using the following code but it inserts only one record:
Patch('[dbo].[SerialNos]', Defaults('[dbo].[SerialNos]'),
{Equipment: varEquipNo,
SerialNumber: "123456",
Loc: varStorLoc
})
How can I modify it to use a range of serial numbers (ex. From SerialNo - To SerialNo) :
Upvotes: 1
Views: 149
Reputation: 87228
There's no direct way to generate a range of numbers in PowerApps currently, but you can use something like the example below:
ForAll(
FirstN(
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20],
Value(txtSerialEnd.Text) - Value(txtSerialStart.Text) + 1),
Patch(
'[dbo].[SerialNos]',
Defaults('[dbo].[SerialNos]'),
{
Equipment: varEquipNo,
SerialNumber: Value(txtSerialStart.Text) + Value,
Loc: varStorLoc
}))
This adds a limit on the size of the range of numbers, but you can add more numbers to the first parameter of FirstN
if you want to support a wider range of values.
Upvotes: 1