function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nil_von_9wonil_von_9wo 

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? 

 

Best Answer chosen by Admin (Salesforce Developers) 
nil_von_9wonil_von_9wo

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

wesnoltewesnolte

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 

nil_von_9wonil_von_9wo

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>

 

 

 

sfdcfoxsfdcfox
RecordType is a complex field, as it represents an object (the same as Account on Contact represents an object). As such, it doesn't exist by itself; it's used to reference fields on the related object. If you want the ID of the record type, use RecordTypeId or RecordType.Id. If you want the name of the record type, use RecordType.Name. Also, if you're not using Record Types on an object, that field won't appear in your describe calls, and queries that use it will fail saying that the field does not exist.
nil_von_9wonil_von_9wo

sfdcfox wrote:
If you want the name of the record type, use RecordType.Name. 
 Cheers for that: it fixed the Record Type problem.  :-)
 
 Now, I need to know how to fix the Lead problem.... 

 

aballardaballard
You can get the lead source as   {!Opportunity.LeadSource}, which is a string value....  but you seem to be expecting a lead object.   Where do you expect it to come from?  Is it a custom relationship field you have added to Opportunity?   There is no lead field defined on opportunity. 
nil_von_9wonil_von_9wo

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.  :-) 

This was selected as the best answer