function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bzain9bzain9 

Creating custom button to generate an invoice

I am new when it comes to visualforce and creating custom controllers. 

I have a problem to solve where each Account needs the ability to quickly add an Invoice with only 1 Invoice line item. The ask is to be able to click a button on the Account and be prompted to enter the quantity prior to creating the invoice. 
The result should be after the quantity is entered, an Invoice record is created with 1 Invoice line item showing the fields price and quantity.

Help with how the code should be written would help a lot.

 
Best Answer chosen by bzain9
Amit Jadhav 13Amit Jadhav 13
hey Bzain
1)You need 2 vf page 1 st page is editable formate means input page and create a custom button pass 1st page id in that and that button add in account page layout.
2)create a 2nd page formate renderd as pdf is your actual invoice you can genrate and store in line item 
3)in 2nd page past 1st page code and change type input to output 
4)in 1st page create a method for button and add command button in that page and pass 2nd page id and another button add account object id

if you solve you problem please mark best Answer
 

All Answers

Amit Jadhav 13Amit Jadhav 13
hey bzain can you discribe your requirement and where you can store invoice in Notes and Attachment or else 
bzain9bzain9
So the complete ask is: 

Corent, a new client of ours, has a requirement that each Customer Account will need the ability to quickly add an Invoice with only 1 Invoice line item. The Corent Project Lead has requested that we default the price for the Invoice line item as $150.00, but they should be able to change it themselves in the future if they want to. Corent's Customer Accounts will be purchasing their new Product, Corent Play. They have also stated that they would like to click a button on the Account and be prompted to enter the quantity prior to creating the Invoice. He would also like to view the defaulted price of Google Stadia. 

Using Lightning (or VisualForce) and Apex, create a new button on Customer Accounts and be able to enter the quantity and create an Invoice record with 1 Invoice line item that's showing the price, quantity and Product, Corent Play.

Where invoices are stored are completely up to the developer.
Amit Jadhav 13Amit Jadhav 13
hey Bzain
1)You need 2 vf page 1 st page is editable formate means input page and create a custom button pass 1st page id in that and that button add in account page layout.
2)create a 2nd page formate renderd as pdf is your actual invoice you can genrate and store in line item 
3)in 2nd page past 1st page code and change type input to output 
4)in 1st page create a method for button and add command button in that page and pass 2nd page id and another button add account object id

if you solve you problem please mark best Answer
 
This was selected as the best answer