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

Contact Role functionality for Custom Object



I am looking to develop below functionality for Custom Object.

Contact Role Functionality


I am creating child records for opportunity record. By standard way I can create single record at a time. But I am looking to build above functionality. So that user can create multiple child records at a time. How we can do it using vf and apex classes?




Anup JadhavAnup Jadhav

short answer: You can build a custom visualforce page and controller to achieve this functionality.


long answer:  there are more than one way to implement this functionality. You can either build a custom visualforce page wherein the user can enter information for more than 1 record and then submit the page which inserts multiple records.



- Anup


Thank you Anup for your response.


I am using the wrapper class to insert multiple records at one go.


At the same time, I want to display already inserted records on the same VF page.


For example:


I am inserting multiple child records for particular parent. At the first time there are no child records. So therefore I am allowing user to enter multiple records. So user enters the multiple records first time.


When user wants to insert more child records next time, and he clicks on New button of related child record. It will open the same VF page. But at this time, I want to display previously inserted records too. (As it is their in Contact Role). So that user can update previously records.


I am stuck in displaying previously inserted records on that VF page.


How could be done this functionality? Does wrapper class is the best way to do this?





Anup JadhavAnup Jadhav

You can retrieve the previously inserted records created by that user or against that account using SOQL. If the SOQL returns any records then display these on the page using a custom pageblock table etc. If there are no records returned then don't display anything when the page is loaded.


You'd have to this in the constructor or on the page load action.


- anup


Once again thank you for the response.


I am able to retrieve previously inserted records using soql. These records are in the account list.


At the same time I would like to show input fields to insert more records (3 records) As it is displayed on Contact Role.


I am not able to combine these two functionalities.