I've been having some problems with replacing a Standard controller view with a Visualforce page following this: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_tabs.htm
The problem is, it's breaking a lot of my apex classes. For example, anything that uses:
ApexPages.currentPage().getParameters().get('id')
Which will throw this error:
Id value is not valid for the Property__c standard controller
Is there another way to get record ids using visualforce pages? We use these frequently
Here is one example of a code that is breaking:
public class ControllerCreateProposalView {
public Id lId;
public String convertedId;
public ControllerCreateProposalView(ApexPages.StandardController stdController){
lId = ApexPages.CurrentPage().getParameters().get('id');
System.Debug('#######leadId:' + lId);
}
public PageReference convert(){
Property__c l = [SELECT Id, name, Primary_Contact__c, Primary_Contact__r.id,Store_Number__c, Last_Sale_Date__c, Square_Footage__c, Last_Sale_Price__c, Anchor_GLA__c, CAP_Rate__c, Year_Built__c, Lot__c, Year_Renovated__c, Occupancy__c, Zoning__c, External_ID_APN__c, Number_of_Buildings__c, Number_of_Retail_Units__c, Loan_Balance__c, Maturity_Date__c, Interest_Rate__c, Term__c, Original_Lease_Term__c, Options__c, Term_Remaining_on_Lease__c, Gross_Leasable_Area__c, Type_of_Ownership__c, Parking__c, Parking_Ratio__c, Lease_Type__c, Date_Reported__c, Loan_Amount__c, Loan_Type_bcc__c, LTV__c, Lender__c, Lender_Type__c, Amortization__c, Recourse__c, Current_Interest_Rate__c, Payment__c, Prepayment__c, Proposal_date__c FROM Property__c WHERE Id=:lId LIMIT 1];
Proposal__c c=new Proposal__c(Name=l.Name, Property__c=l.Id, Client__c=l.Primary_Contact__c, Square_Footage__c=l.Square_Footage__c, CAP_Rate__c=l.CAP_Rate__c, Lot__c=l.Lot__c, Loan_Balance__c=l.Loan_Balance__c, Maturity_Date__c=l.Maturity_Date__c, Term__c=l.Term__c, Original_Lease_Term__c=l.Original_Lease_Term__c, Options__c=l.Options__c, Term_Remaining_on_Lease__c=l.Term_Remaining_on_Lease__c, Anchor_GLA__c=l.Anchor_GLA__c, Occupancy__c=l.Occupancy__c, Number_of_Buildings__c=l.Number_of_Buildings__c, Number_of_Retail_Units__c=l.Number_of_Retail_Units__c, Gross_Leasable_Area__c=l.Gross_Leasable_Area__c, Type_of_Ownership__c=l.Type_of_Ownership__c, Parking__c=l.Parking__c,Parking_Ratio__c=l.Parking_Ratio__c, Year_Built__c=l.Year_Built__c, Lease_Type__c=l.Lease_Type__c, Date_Reported__c=l.Date_Reported__c, Loan_Amount__c=l.Loan_Amount__c, Loan_Type__c=l.Loan_Type_bcc__c, LTV__c=l.LTV__c, Lender__c=l.Lender__c, Interest_Rate__c=l.Interest_Rate__c, Lender_Type__c=l.Lender_Type__c, Amortization__c=l.Amortization__c, Recourse__c=l.Recourse__c, Current_Interest_Rate__c=l.Current_Interest_Rate__c, Payment__c=l.Payment__c, Prepayment__c=l.Prepayment__c);
insert c;
l.Sales_Status__c = 'Proposal';
l.Proposal_Date__c=Date.today();
update l;
convertedId = c.Id;
String cID=l.Primary_Contact__r.id;
System.Debug('<>PROPOSAL<> :' + l );
System.Debug('<>CEYEDEE<><>cID<><>CEYEDEE<> :' + cID );
//update contact stage
List<Contact> contacts=[SELECT Id, Sales_Status__c FROM Contact WHERE id=:cID];
System.Debug('<>LIST<><>contacts<><>LIST<> :' + contacts );
if(contacts.size()>0){
for(Contact i: contacts)
{
if(i.Sales_Status__c=='Unconfirmed'||i.Sales_Status__c==NULL){
i.Sales_Status__c='Proposal';
update i;
}
}
}
String sServerName = ApexPages.currentPage().getHeaders().get('Host');
sServerName = 'https://'+sServerName+'/';
System.Debug('#######sServerName :' + sServerName );
String editName='/e?retURL=%2F'+convertedId;
PageReference retPage = new PageReference(sServerName + convertedId+editName);
System.Debug('#######retPage :' + retPage );
retPage.setRedirect(true);
return retPage;
}
public PageReference back(){
String sServerName = ApexPages.currentPage().getHeaders().get('Host');
sServerName = 'https://'+sServerName+'/';
System.Debug('#######sServerName :' + sServerName );
PageReference retPage = new PageReference(sServerName + lId);
System.Debug('#######retPage :' + retPage );
retPage.setRedirect(true);
return retPage;
}
}
edit I'm adding this controller extension that the page is using along with the standard controller, in case that makes a difference.
public class PropertyExtensionController{
Property__c property;
public PropertyExtensionController(ApexPages.StandardController controller)
{
property = (Property__c)controller.getRecord();
}
public PageReference save()
{
update property;
return null;
}
}
Property__c
object. Usually, this means you're trying to assign the wrong value somewhere. Unfortunately, what exactly is wrong is hard to tell, because you didn't include any useful code here. Can you provide a Short, Self Contained, Correct (Compilable), Example so we can triage your code?https://xxxxx.visual.force.com/apex/PropertyTestTabs?id=xxxxxxxx
Instead ofhttps://xxxxx.salesforce.com/xxxxxxx
Not sure how to rewrite this part to get the record idretpage
will have to be reprogrammed, but before I do this, I need to get the recordid in the first placel
for custom objectproperty__c
? Did this code evolve from something about leads and the lead ID is being passed in the URL?