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
VPrakashVPrakash 

Can we add multiple child records to a parent record using apex and visualforce page?

Hi all, 

 

Here is the scenario, We have a contract object to which contract line items is a child object. We want to add multiple contract line items to the contract object. Contract line items are nothing but the products with some extra fields. Like we add opp line items to the opportunities as in standard functionality. Can we do this for my scenario using apex and visualforce. Is this possible? 

 

Thanks in advance 

 

--VPrakash

sdetweilsdetweil

don't see why not.. the contractlineitem would need a 'parent' contract ID field

 

so you would get the id of the contract, then create contractlineitems where the contractid is the one you found before.

 

Sam

BangwWthSalesforceBangwWthSalesforce

Yes , we can do this by using standard functionallity. just make a relationship between product & Contarct. So that contract will pe parent & product will be chalid. So u can add as many contract line items in a contract...

VPrakashVPrakash

Hi all,

 

The thing is we want to add multiple records at a time  through the UI as we add multiple products to the opportunity as opp line items and edit the discount, saleprice and date  in the next screen. I mean to say I want to clone the whole process of creating opp line items using apex and visualforce. Can we do this? If so can you please provide me with the sample code and resources. 

 

 

Thanks

 

--VPrakash

DRobi83DRobi83

Im looking to do this also.

 

The closest i can find is this code, but I think there should be something before it in the class? anyone got any ideas to expand on this?

 

list<miiFinance__Invoice_Line_Item__c> lstobject = new list<miiFinance__Invoice_Line_Item__c>();
 public void AddLineItem(){
        objectname obj = new objectname();
        lstobject.add(obj);
    }//eof Add Line Item

 public list<miiFinance__Invoice_Line_Item__c> getobjectDetails(){

                return lstobject;

        }

 

 

prateek1.3896034732055803E12prateek1.3896034732055803E12
Hi Drobi83 were you able to achieve this , I am also looking for same functionality, could you please share the code at this post or email greenprateek@gmail.com