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
cwarheitcwarheit 

Can I do this in VisualForce?

I have a client that needs to have phone lines with their properties (call waiting, call forwarding, etc) to be associated with an opportunity.  So, I've created a custom object called Phone Lines and created all of the fields.  When the users are creating the opportunity and adding phone lines, there is nearly always more than one and sometimes can be 20 or more (If the number is too high, we'll just import).  Often the phone lines have the same properties, so ideally, there should be a way for them to add a line and then instead of saving and going through the process of adding another line, I'd like a button that will allow them to save that number and bring back the form with the same properties selected, except the line number.  Since this has a lot of customization, I figured it would be best using VisualForce, but outside of the basic tutorials, I have no practical VF experience and would like a little guidence.  What I'd like to do is this: 
1. When they enter a phone number, and click the "save & clone" (or something like that), I would like to stick the data from the first number in an array
2. Take the properties of the last saved number  and repopulate the form minus the number. 
3. The user will continue to do this until they have entered all the numbers that they need to enter
4. The user would then click a "finish" button and that would take the data from array and save the data in the database.

Can anyone give me some recommendations?  Can I use VF for this?  I've been looking for arrays and all I can find are Lists - are lists arrays in APEX?

Any help or advice would be appreciated.
jeremy_rossjeremy_ross
First, I'll caution you that this is somewhat complex for your first VF project. That being said, one way to accomplish this would be to have the input fields necessary to create one phone line and then some type of table or repeater to display the phone lines that exist for the opportunity.  The user could populate the information for a phone line, hit submit, and then some AJAX stuff could create the new phone line and refresh the table of phone lines.  If you're interested in this approach, check out outputPanel, and the section on AJAX in the docs http://www.salesforce.com/us/developer/docs/pages/index_CSH.htm#pages_quick_start_ajax.htm.

There is no raw array in Apex.  Instead there's List, which most likely have the algorithmic properties of being backed by an array.

Jeremy