You need to sign in to do that
Don't have an account?
Mathew Andresen 5
edit page for visualforce page of object
Hi,
I have created a visualforce page to replace the standard page of my detail object (in this case Client_Plan__c as master, and Client_Plan_Product__c as detail). This seems to be working fine for creating a new record, or save and new for a record. However, when I try to go into edit mode from the parent object I get the error
"SObject row was retrieved via SOQL without querying the requested field: Client_Plan_Product__c.Type__c "
Here is the URL that is getting passed in on the failed edit
"https://c.cs13.visual.force.com/apex/ClientProductPage?id=a0eW0000001t54N&retURL=%2Fa0QW0000002ILIY&sfdc.override=1"
I'm not quite sure what I'm doing wrong
thanks,
I have created a visualforce page to replace the standard page of my detail object (in this case Client_Plan__c as master, and Client_Plan_Product__c as detail). This seems to be working fine for creating a new record, or save and new for a record. However, when I try to go into edit mode from the parent object I get the error
"SObject row was retrieved via SOQL without querying the requested field: Client_Plan_Product__c.Type__c "
Here is the URL that is getting passed in on the failed edit
"https://c.cs13.visual.force.com/apex/ClientProductPage?id=a0eW0000001t54N&retURL=%2Fa0QW0000002ILIY&sfdc.override=1"
I'm not quite sure what I'm doing wrong
thanks,
public class ClientProductClass { public Client_Plan_Product__C prod {get; set;} string prodId; string clientId; String retUrl; public ClientProductClass(ApexPages.StandardController stdcon) { prodId = ApexPages.currentPage().getParameters().get('id'); // access the product id from the URL clientId = ApexPages.currentPage().getParameters().get('CF00N50000003LQm5_lkid'); // access the product id from the URL if (prodId != null && prodId !='') { System.debug('id = ' +prodId); prod=(Client_Plan_Product__c)stdcon.getRecord(); } else { prod = new Client_Plan_Product__c(); prod.Client_Plan__C = clientId; } } public PageReference save() { upsert prod; // returns the page to the parent object after savings Client_Plan__c plan = new Client_Plan__c(id=prod.Client_Plan__c); PageReference clientPage = new ApexPages.StandardController(plan).view(); clientPage.setRedirect(true); return clientPage; } public PageReference Cancel() { return null; } public PageReference saveNew() { upsert prod; prod = new Client_Plan_Product__c(); prod.Client_Plan__C = clientId; PageReference clientPage = new ApexPages.StandardController(prod).view(); clientPage.setRedirect(true); return clientPage; } }
public class ClientProductClass { public Client_Plan_Product__C prod {get; set;} string prodId; string clientId; String retUrl; public ClientProductClass(ApexPages.StandardController stdcon) { prodId = ApexPages.currentPage().getParameters().get('id'); // access the product id from the URL clientId = ApexPages.currentPage().getParameters().get('CF00N50000003LQm5_lkid'); // access the product id from the URL if (prodId != null && prodId !='') { System.debug('id = ' +prodId); prod=(Client_Plan_Product__c)stdcon.getRecord(); } else { prod = new Client_Plan_Product__c(); prod.Client_Plan__C = clientId; } } public PageReference save() { upsert prod; // returns the page to the parent object after savings Client_Plan__c plan = new Client_Plan__c(id=prod.Client_Plan__c); PageReference clientPage = new ApexPages.StandardController(plan).view(); clientPage.setRedirect(true); return clientPage; } public PageReference Cancel() { return null; } public PageReference saveNew() { upsert prod; prod = new Client_Plan_Product__c(); prod.Client_Plan__C = clientId; PageReference clientPage = new ApexPages.StandardController(prod).view(); clientPage.setRedirect(true); return clientPage; } }
Please check if this helps.
All Answers
Hi Mathew,
Please add this line in your constructor first line. e.g. after line 9 and see if this resolves the issue.
stdcon.addFields('Type__c');
if it works please mark this answer as solution for sure.
Thanks
Amit
Also, I get the following error when I try "stdcon.addFields('Type__c');"
Method does not exist or incorrect signature: [ApexPages.StandardController].addFields(String)
prod.addFields('Type__c');
Please try this code.
FYI : I noticed that your VF pageblock table needs '!prod' as List but it is not a list in controller.
"Method does not exist or incorrect signature: [ApexPages.StandardController].addFields(String)"
Please check if this helps.