Summary
Add a Purchase Order and store result set
ClearCollect(purchaseOrderResultSet,Patch('Purchase Orders',Defaults('Purchase Orders'),{'Vendor No.':ComboBox1.Selected.'No.','Pay-to Vendor No.':ComboBox1.Selected.'No.'}))
Update an existing Purchase Order
Patch('Purchase Orders',First(purchaseOrderResultSet),{'Vendor No.': ComboBox1.Selected.'No.','Pay-to Vendor No.':ComboBox1.Selected.'No.'})
Add Purchase Order Lines
Patch('Purchase Order Lines',Defaults('Purchase Order Lines'),{'Document Id':First(purchaseOrderResultSet),'Line Type':dyn365bc_invoicelineagglinetype_v2_0.Comment,'Description':TextInput1.Text})
Patch('Purchase Order Lines',Defaults('Purchase Order Lines'),{'Document Id':First(purchaseOrderResultSet),'Line Type':dyn365bc_invoicelineagglinetype_v2_0.Item,'Item Id':ComboBox2.Selected,Quantity:10})
I created a Canvas app
I named the Canvas app "Purchase Orders App"
I clicked the Data tab
I added the Business Central "Vendors" Table
I added the Business Central "Items" Table
I added ComboBox1 allowing the user to select a Vendor
I added ComboBox2 allowing the user to select an Item
I added TextInput1 allowing the user to enter a comment
I added a "Create a Purchase Order" Button
I added an "Update the Purchase Order" Button
I added an "Add a Comment Purchase Order Line" Button
I added an "Add an Item Purchase Order Line" Button
I added the Business Central "Purchase Orders" Table
I added the Business Central "Purchase Order Lines" Table
I added OnSelect code to the Create a Purchase Order button
I reviewed the purchaseOrderResultSet collection returned (the single row)
I added the OnSelect code to the "Update the Purchase Order" button
I selected "First Up Consultants" and clicked the "Update the Purchase Order" button
I added the OnSelect code to the "Add a Comment Purchase Order Line" button
I entered "Example Comment" into the text input and clicked the "Add a Comment Purchase Order line" button
I reviewed the Purchase Order and the Comment Purchase Order Line
I added the OnSelect code to the "Add an Item Purchase Order Line" button
I selected the "ATHENS Mobile Pedestal" item
I clicked the "Add an Item Purchase Order Line" Button
I reviewed the newly created "ATHENS Mobile Pedestal" Purchase Order Line