PowerApps Invoice Generator – Tutorial Mini Series Episode 3 – Building the PowerApp

PowerApps Invoice Generator – Mini Series Episode 3 – Building the PowerApp

If you would like to explore more or sign up to Microsoft 365 here are some useful links:

– Learn more about Microsoft 365 for business:
https://click.linksynergy.com/fs-bin/click?id=hPnKNOblu9k&offerid=817940.21&type=3&subid=0

– Compare Microsoft 365 Enterprise Plans:
https://click.linksynergy.com/fs-bin/click?id=hPnKNOblu9k&offerid=817940.22&type=3&subid=0

– Reimagine productivity with Microsoft 365 and Microsoft Teams: https://click.linksynergy.com/fs-bin/click?id=hPnKNOblu9k&offerid=817940.9&type=3&subid=0

**WeTechCareOfYou is registered with Microsoft’s Affiliate programme and earn a commission from purchases made through the above links.

Code

“Add Row” Button – OnSelect:
Collect(
InvoiceRowsCollection,
{
ColDescription: DescriptionInput.Text,
ColUnits: UnitsInput.Text,
ColTotalAmount: TotalAmountInput.Text
}
);
Set(RawVar, Substitute( TotalAmountInput.Text, “$”, “” ));
Set(RawVar2, Substitute( RawVar, “,”, “” ));
Set(VarTotalValue, VarTotalValue + Value(RawVar2));
Set(VarGST, VarGST + Value(RawVar2)*.2);
Reset(DescriptionInput);
Reset(UnitsInput);
Reset(TotalAmountInput);
Set(FormattedNum, “”);

Sale Amount – Default:
Text( Value(VarTotalValue), “[$-en-GB]$#,###.00” )

GST – Default:
Text( Value(VarGST), “[$-en-GB]$#,###.00” )

Balance Due – Default:
Text( Value(VarTotalValue) + Value(VarGST), “[$-en-GB]$#,###.00” )

TotalAmountInput – OnChange:
Set(FormattedNum,
Text(
Value(TotalAmountInput.Text),
“[$-en-GB]$#,###.00”
);
)

TotalAmountInput – Default:
FormattedNum

App – OnStart:
Set(InvoiceNum, “INV-” & Last(‘Invoice System Demo’).ID + 1)

Bin:
Set(RawVar, Substitute( ThisItem.ColTotalAmount, “$”, “” ));
Set(RawVar2, Substitute( RawVar, “,”, “” ));
Set(VarTotalValue, VarTotalValue – Value(RawVar2));
Set(VarGST, VarGST – Value(RawVar2)*.2);
Remove( InvoiceRowsCollection, ThisItem)

Submit Button – OnSelect:
SubmitForm(Form1)

Form1 – OnSuccess:
ForAll(InvoiceRowsCollection, Patch(‘Invoice System Demo Tasks’, Defaults(‘Invoice System Demo Tasks’), { Title: “Invoice Task”, Description: ColDescription, Units: Value(ColUnits), ‘Total Amount’:ColTotalAmount, FormID: Form1.LastSubmit.ID}));
Notify( “Your invoice was successfully submitted”, NotificationType.Success, 5000);
NewForm(Form1);
Clear(InvoiceRowsCollection);
Set(VarTotalValue, 0);
Set(VarGST, 0);
ResetForm(Form1);
Set(InvoiceNum, “INV-” & Last(‘Invoice System Demo’).ID + 1)

You can watch the full video here:
https://youtu.be/b0bYXWiEzmo