I have created a VF page. The main requirement is when ever the data is entered and saved, then some fields should be saved in one object and the remaining in other object....
Can anyone pls help in writing the controller as per the requirement....
Create a controller class , add the code to the extent of your knowledge, let me know once it is done, I will help you in finishing the remaining thing.
Ok, Then in the constructor of the controller class get the record from the main object and using main object's id get the record from second object. In the save method update fields in to the respective objects and save them.
Hi,
Create a controller class , add the code to the extent of your knowledge, let me know once it is done, I will help you in finishing the remaining thing.
Regards,
Sridhar Bonagiri
We can do many ways for this. One of the way is below.
Page:
Hi Sridhar,
Here is my controller....
public class ContactUpdateController {
public PageReference cancel() {
return null;
}
public ContactUpdateController() {
}
public Shipping_Vendor__c vendor {get; private set;}
public Shipping_Vendor_Contact__c contact {get; private set;}
public ContactUpdateController(ApexPages.StandardController controller) {
vendor=new Shipping_Vendor__c();
contact=new Shipping_Vendor_Contact__c();
}
public boolean getRecordNameRetrieval(){
String recordTypeName=ApexPages.currentPage().getParameters().get('RecordType.Name');
if(recordTypeName.equals('B2C'))
return true;
return false;
}
public PageReference save() {
try{
insert(vendor);
}
catch(System.DMLException e){
ApexPages.addMessages(e);
return null;
}
return (new ApexPages.StandardController(vendor)).view();
}
}
Hi,
Are you using this controller as extension controller or custom controller in VFP? what is the standard controller?
Regards,
Sridhar Bonagiri
It is the extension controller.................
Hi,
Ok, Then in the constructor of the controller class get the record from the main object and using main object's id get the record from second object. In the save method update fields in to the respective objects and save them.
Let me know if you need more help.
Regards,
Sridhar Bonagiri