+ Start a Discussion
dsh210@lehigh.edudsh210@lehigh.edu 

New to SOQL/SOSL

Hey all,

 

So I have done minimal work with SOQL/SOSL, so I thought the community might be able to help me out with this beginner question. I am trying to query a custom object I have for the name. I am running a custom visualforce page that looks up various attributes of the object. So in my case the instance of my Model Definition object is called "Model 1" (stored as Model Definition Name). I would like to print the name of the instance at the top of the page since that is a lot more user friendly. I am thinking I would construct a query along the lines of...

 

SELECT 'Model Definition Name' FROM Model_Definition__c WHERE Model_Definition__c = :modelDefId

 

I got the modelDefId from the current page using ApexPages.currentPage().

 

It doesn't like the format of that Model Definition Name though. If I try to use Model_Definition_Name__c, it says that field does not exist on the object. Any suggestions on how to reference it or if I am even setting up this query correctly?

 

Thanks!

SchuetzlerSchuetzler

Use the field name instead of the field label. Go to Setup --> Create --> Objects and Select Model Definition from that list. Click the field label for Model Definition Name. The Field Name will be listed on the page that comes up. Using that should work.

SchuetzlerSchuetzler

If that doesn't work try the API name.

mtbclimbermtbclimber

That's probably the object's "Name" field which through the API is referred to using the value name .  As a beginner it is very helpful to have access to a tool that will describe your organization-specific metadata.

 

If you use a mac then I like the soqlxplorer as a light-weight solution for this specific issue, there's also the force.com IDE which includes a schema browser as well. Both provide SOQL building tools to help you validate and test them visually.

 

If you don't have access to install something or just want to look something up quickly the API name info can be found in setup by navigating to the detail view of the field definition and also by downloading the enterprise wsdl file from setup > develop > API.