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
Arvind010Arvind010 

How to assign Parent object Id to the child objects in the extension classes?

Hi,

 

We have a VF page, with a std controller, 3 extension classes and it calls 2 VF components. Each ext class has individual save methods. We are calling the save methods from VF page using apex:actionFunction and script. VF page code is:

 

<apex:page standardcontroller="Order_Line_Item__c" extensions="CW_ServiceSummary_ACL,AccessPort,RouterCardsTab">
<apex:form id="theform">
<apex:actionFunction action="{!AccPortSave}" name="AccPortSave" rerender="abc"/>
<apex:pageBlock id="abc">
<script>
function saveall(){
cmdSave();
AccPortSave();
return true;
}
</script>
<apex:commandButton value="Save" rerender="abc" oncomplete="saveall()"/>
<c:AccessPortComp/>
<c:RouterCardsComp/>

</apex:pageBlock>
</apex:form>
</apex:page>

 We are inserting parent record in the first extension class. Code is given below.

 

global class CW_ServiceSummary_ACL
{
public void cmdSave(){
try{
objOrderLine.Product__c=PL.Product_Name__c;
objOrderLine.Product_Group__c=PL.Product_Group__c;
objOrderLine.IPVPN_QoS_Service_Option__c=PL.Service_Option__c;
Upsert objOrderLine;
objOrderLineId = objOrderLine.Id;
}
catch(Exception e){system.debug('eeeeeee:'+e);}
}
}

 

We are assigning the parent obj id to the child objects in the rest of the extension classes. In the below class, parentobj id is null in the save method. I am doubting that, the place where we are getting the orderlineid(parent obj id) in the constructor (AccessPort) code is wrong. 

global class AccessPort{
private Order_Line_Item__c ParentId=null;
public AccessPort(ApexPages.StandardController con) {
OrderLineId=(Order_Line_Item__c)con.getRecord();
}
public void AccPortSave(){
try{
system.debug('Parent obj id:'+ParentId.Id);
for(Integer i=0;i<Accport.size();i++){
Accport[i].Order_Line_Item__c=ParentId.Id;
}
Upsert Accport;
}
catch(Exception e){}
}
}

 

 Please anyone suggest us to get the parent obj id in the extension class. This is very critical.