You need to sign in to do that
Don't have an account?

Problem with salesforce_useful_scontrols: conditional override
Currently trying to work through this tutorial, found on page 4, but having at least two problems.
After embedding the code from the book into a VisualForce page with standardController="Opportunity"
First, without the JavaScript, when I save I get this error:
Save error:
SELECT id, name, recordtype FROM Opportunity WHERE
^
ERROR at Row:1:Column:18
No such column 'recordtype' on entity 'Opportunity'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
I added a record type to Opportunity in order to fix this, but it didn't help.
2. If I comment out the reference to {!Opportunity.RecordType}, I get the error:
Unknown property 'OpportunityStandardController.Lead'
I tried to change references to "Lead" to "LeadSource", but that only resulted in the error changing to
Unknown property 'OpportunityStandardController.LeadSource'
Any ideas how to fix these?
I just realized I was a little too tired and too used to finding errors in the SalesForce docs... it seems the script was supposed to be an unrelated SControl.
I guess that problem is solved too. :-)
All Answers
Hey
I'm not sure which tutorial you're working with but Opportunity doesn't have a recordtype field that I can see, so creating it would be correct. You would then need to change the SELECT statement to read
SELECT id, name, recordtype__c FROM Opportunity WHERE
WRT your second question could you post some code or link to the tutorial.
Cheers,
Wes
The odd thing is, I am not making the SELECT statement... Salesforce seems to be generating it based on the page content. If I add "__c" to the recordType, I get another error telling me the field doesn't exist, and if I look in SalesForce, in face the name of the field doesn't include the "__c".
This is the code on the page:
<apex:page standardController="Opportunity" tabstyle="Opportunity" id="thePage"><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Add Product Override</title> <script type="text/javascript" src="/soap/ajax/8.0/connection.js"></script> </head> <body> <h1>Opportunity Info:</h1> <p>Opportunity Id: {!Opportunity.Id}</p> <p>Opportunity Name: {!Opportunity.Name}</p> <p>Opportunity Record Type: {!Opportunity.RecordType}</p> <script type="text/javascript"> //determine if the lead has been open longer than 30 days if ( {!IF( ISPICKVAL (Lead.Status, "Open"), ROUND(NOW() - Lead.CreatedDate, 0), 0 ) } > 30 ) { // more than 30 days - display a custom scontrol page window.location.href="{!URLFOR($SControl.EditLeadsOpenLongerThan30)}"; } else { // 30 days or less - display the standard edit page window.parent.location.ref = "{ !URLFOR( $Action.Lead.Edit, Lead.Id, [retURL=URLFOR($Action.Lead.View, Lead.Id)], true ) }"; } </script> </body></html></apex:page>
I just realized I was a little too tired and too used to finding errors in the SalesForce docs... it seems the script was supposed to be an unrelated SControl.
I guess that problem is solved too. :-)