You need to sign in to do that
Don't have an account?
After deleting child record page should redirect to master record...
hi friends,
i have created two object named as vendor and vendor contact(master-detail relationship)...
i have used visualforce page (to create,to edit,detail page etc) for both vendor as well as vendor contact too...
whenever i delete any vendorcontact record from its detail page,after deletion it goes to list view of vendor contact... here i want that it should get back to respected master record.... for this i have created class to override delete button but getting error like this..
System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Vendor_Contact__c.Vendor__c
Class.DeleteVendorContactExtension.CheckDelete: line 19, column 14 External entry point
here is my code
vf page
<apex:page standardController="Vendor_Contact__c" extensions="DeleteVendorContactExtension" action="{!CheckDelete}">
</apex:page>
extension
public class DeleteVendorContactExtension
{
private Id JobId;
private final Vendor_Contact__c objVC;
public DeleteVendorContactExtension(ApexPages.StandardController controller)
{
this.objVC=(Vendor_Contact__c)controller.getrecord();
}
public PageReference CheckDelete()
{
JobId = objVC.Vendor__c;
try
{
// String strid;
// strid = objVC.Vendor__c;
Database.delete(objVC);
}
catch(System.DMLException e)
{
return null;
}
PageReference p = new Pagereference('/apex/VendorListView?id'+JobId);
p.setRedirect(true);
return p;
}
}
Thanks in advance
missed such small thing
try this
OR
All Answers
Change constructor to this
Thanks Shashi, but now i am getting error like this
System.FinalException: Final variable has already been initialized
Class.DeleteVendorContactExtension: line 4, column 37 External entry point
Ohh I missed that its declared as final
try this
This is the error i am getting right now
missed such small thing
try this
OR
Thank you Shashi!!!