• Seema A
  • 0 Points
  • Member since 2011

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 11

I have previously made use of the AJAX Toolkit to create a generic VF component that displays selected fields of any sObject in a user-friendly grid, using the ExtJS library.  I was excited to give the new REST API a try, thinking that it would be both simpler and more performant than the SOAP-based Toolkit.


I've started coding up a new VF page using this approach, but have run into a fairly major stumbling block.  The XHR request is mysteriously failing; as far as I can tell it is because my Visualforce pages are of the form c.na7.visual.force.com/apex/whatever, while the REST API lives at na7.salesforce.com/services/data/v20.0, and this is considered to be a different "domain".


Have I correctly diagnosed the source of my problem?  If so, is there a chance for REST access in the future?



Jeff Trull


Hey guys,I have problem about Dynamic Visualforce Bindings . That is Spring 11 edition's new function .

Then,I want display a Date type field and edit it, so  i use <apex:inputField >.

But it isn't same to system. I get a text !


Guys, I want to know how to display a date type field whit dynamic , and can be edit it like system.


Any help would be extremely appreciated!



Hello folks,

Is there a way to override the 'Share' button on the chatter window ? Im trying to find a way to enable chatter for our Org and make it available for only certain profiles. Looks like there is no straight forward way to do this. This being the case, if I can override the share button or if I can find a way to write a trigger on 'SHARE' , I can display user friendly warnings to the profiles that are not allowed to use Chatter.


Appreciate your thoughts folks.




First off, please read the WHOLE message before replying.  Everyone seems to read the error message and stop there...  Thanks. :)


So I came across this error when doing something relatively simple and after narrowing it down, it seems to be a problem with SalesForce itsself.  First the error:


SELECT id FROM Lead WHERE ((CampaignId = '701xxxxxxxxxxxxx') ^ ERROR at Row:1:Column:29 No such column 'CampaignId' on entity 'Lead'. 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.



Here's how to reproduce it. 


 Apex Page: 



<apex:page standardController="Lead" extensions="leadsextension" recordSetVar="leads" id="leadslist"></apex:page>


Apex Class (leadsextension.cls):



public class leadsextension{ private List<Lead> leads; public Integer leadsCount { get; private set; } public leadsextension( ApexPages.Standardsetcontroller stdSetCtrlr ) { leads = (List<Lead>)stdSetCtrlr.getSelected(); } }


Add the page as a custom button to the leads list view, check some leads and click the button.  Everything so far works fine.  Now the problem.  Create a lead view with a campaign as a filter.  Load that list, check some leads and click the new button... ERROR!  Maybe I'm being stupid and someone can lead me out of the darkness.  Help!



Message Edited by bikerdan2112 on 01-04-2010 01:15 PM
Message Edited by bikerdan2112 on 01-04-2010 04:49 PM

I built a VF page to override the change lead status functionality. We require that a Reason Rejected field value is selected when setting the Lead Status = Rejected so I dynamically render the Reason Rejected when Rejected is selected from the select box. Everything works great...except when the user presses the button from a lead list view that is filtered by a Campaign. When they attempt to do so, instead of seeing my custom page, they get something like:


LastName, status FROM Lead WHERE ((CampaignId = '701T00000001cZo') ^ ERROR at Row:1:Column:83 No such column 'CampaignId' on entity 'Lead'. 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.


My VF page references the standard Lead controller. Do I really need to create a custom controller just to make this work?


Hey everyone. I've been working with Dynamic Apex. I may not be understand how to use it correctly but here is my scenario.


I have an Unknown Sobject that will have a Look field to the Account object -- but the field name is not the same from Sobject to Sobject (example Account__c vs AccountID). I want to be able to pull the ID of the lookup for a specific Sobject.


My inputs for the Sobject is an ID. So Far I have been able to:


1. Identify the Sobject by parsing the 3 digit key of the ID returning "MySobject"

2. String of all Accessible Fields on the Sobject by looping through the Describ of MySobject and looping through all the field tokens

3. RelatedItem defined through Data Query using MySobject, my All field list and the Input ID

4. Identify the Field Name of the loop field by looping through all the field Tokens and looking at the getRelationshipName() of the token


However, I can't seem to find a valid way of taking my "RelatedItem" (returned through data Query) and get the value from the field in step 4. I know I could create a separate Data Query that will return JUST that field -- but I rather not use a second query when I already have the full object defined from Step 3 (used later).


Is what I"m trying possible? Or am I stuck with having to create an additional query just to get the value of that 1 field?



Hi all,

I am new to SalesForce so I appologise in advance for any newbie mistakes.

I'm trying to make a vf page to display the fields of the SObjects returned by an arbitrary query. I found a working solution for displaying the fields of one object in this thread: dynamicSObject. I have tried to take the accepted solution in the thread and iterate over a list of DynamicSObjects instead of showing just one.

When I try the original solution everything works fine.
The iterative code below uploads ok without any error messages.
When I try to view the page with the new iterative version I get the following runtime error:

 System.Exception: Too many fields describes: 11

Class.queryTestController.DynamicSObject.getFields: line 61, column 46 External entry point

The position mentioned in the error message is in the line below at "getDescribe()"

for (Schema.SObjectField f : getDescribe().fields.getMap().values()) {

What am I doing wrong?

Thank you for your time!




<apex:page controller="queryTestController">

<apex:form >
<apex:inputText value="{!dynamicQuery}" id="dynamicQuery"/>

<apex:form id="content">
<apex:pageMessages />
<apex:repeat var="object" value="{!unknowns}">
<h1>{!object.sobjectType} [{!now()}]</h1><br/>
<apex:pageBlock title="{!object.id}">
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!object.save}" value="Save" rerender="content"/>
<apex:pageBlockTable var="f" value="{!object.fields}">
<apex:column value="{!f.name}" headerValue="Name"/>
<apex:column headerValue="Value">
<apex:inputText value="{!f.value}"/>


public class queryTestController {

private List<DynamicSObject> dynamicSObjects;
public string dynamicQuery { get; set;}

public queryTestController () {
dynamicQuery = 'select name,closedate from Opportunity';

public List<DynamicSObject> getUnknowns() {
dynamicSObjects = new List<DynamicSObject>();
ApexPages.StandardSetController setCon = new ApexPages.StandardSetController(Database.query(dynamicQuery));
List<SObject> base = (List<SObject>) setCon.getRecords();
for (SObject obj : base) {
dynamicSObjects.add(new DynamicSObject(obj));
return dynamicSObjects;

public class DynamicSObject {
public DynamicSObject(SObject delegate) {
this.delegate = delegate;

public ID getID() {
return delegate.id;

public void save() {

public String getSObjectType() {
return getDescribe().getName();

public List<Field> getFields() {
if (fields == null) {
fields = new List<Field>();
for (Schema.SObjectField f : getDescribe().fields.getMap().values()) {
if (f.getDescribe().getType() != DisplayType.ID) {
try {
Field field = new Field(delegate, f);
} catch (System.SObjectException x) {
// Do nothing - just means that the field was not selected in the select list

return fields;

private Schema.DescribeSObjectResult getDescribe() {
return delegate.getSObjectType().getDescribe();

private final SObject delegate;
private List<Field> fields;

public class Field {
Field(SObject delegate, Schema.SObjectField f) {
this.delegate = delegate;
this.f = f;


public String getName() {
return f.getDescribe().getName();

public String getValue() {
Object value = delegate.get(f);
return value != null ? String.valueOf(value) : null;

public void setValue(String value) {
// TODO: Handle remaining data type conversions...
if (f.getDescribe().getType() == DisplayType.INTEGER) {
delegate.put(f, Integer.valueOf(value));
} else {
delegate.put(f, value);

private final SObject delegate;
private final Schema.SObjectField f;




  • May 18, 2009
  • Like
  • 0



I am trying to writh a dymanic class method, which would allow me to pass the sObject and field name as parameters in order to return the value from a single field. I have found the reverences to dynamic SOQL in the apex docs and am able to run a dynamic query to return an sObject which represents a single record of an Account type.


What I am having trouble with is then how to extract the field from that sObject (using the dynamic reference to the field name passed to the method) and return this out of the method as a string.




This is my current class method. At the moment, it is only dynamic for the field, and the sObject is hard-coded as being an Account. I have tried using the DescribeFieldResult method but believe this is not the correct approach.


private Object getObject(Id i, String s){


String r;

String sQuery = 'SELECT Id,' + s + 'FROM Account WHERE Id:= id';

Account a = Database.query(sQuery);

// Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.AS400_ID__c;

//Schema.DescribeFieldResult f = Account.AS400_ID__c.getDescribe();

//r = f.getDefaultValue();

return r;






Hi all,

I'd like to dynamically  render an Sobject to a VF page.

Here is my controller:

private list<SObject> obj;

public void setobj(list<SObject> s){obj=s;} public list<Sobject> getobj(){return obj;}
public PageReference init() {
 obj=[select Name from Account limit 10]; return null; }

Here my VF Page:

<apex:page Controller="Test" action="{!init}">
<apex:repeat value="{!obj}" var="field">
   <apex:inputField value="{!field.Name}"/>

I've got this error message :
Read access not found for null.
I've also tried with outputText, inputText with no success.The only field I've managed to retrieve is the ID.

Any Idea ?