• Manoj Goswami 5
  • NEWBIE
  • 25 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 4
    Replies
Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
HI, 
     I'm unable to view any Tab in my Trailhead Org's Home Page (in Lightning view only, with classic its all fine). I think i messed up the settings while customizing the Home page in a trailhead challange. Need help , I have finished many challanges in this Org only. So creating a new org is off the table. Thanks in advance.
User-added image
I want a list of all Objects in my org and displaying it in a drop down in Visualforce page. The code has compiled but giving unexpected error while getting Preview of VF page.

Controller : 
// Controller
public without sharing class getObjectNamesController {    
    
    public Map<String, Schema.SObjectType> object_Map = Schema.getGlobalDescribe(); 
    public Set<String> objNamesSet = object_Map.keyset();
    
    public List<SelectOption> objNamesList{     
        get{
            Integer i=0;
            for(String myObjName : objNamesSet)
            {
                objNamesList.add(new SelectOption(String.valueOf(i),myObjName)) ; 
                i++;
            } 	    	
            System.debug(objNamesList);   
            return objNamesList ;
        }
        set;
    }
}
VF Page: 
<apex:page controller="getObjectNamesController">
  <apex:form >
      <apex:selectList size="1">
          <apex:selectOptions value="{!objNamesList}"></apex:selectOptions>
      </apex:selectList>
  </apex:form>
</apex:page>
User-added image

 
Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
The error message states there is an error in column 3 line 1



trigger Region_cLeadTrigger on Lead (before insert) {

    staticResource sr = [
        select Body
        from StaticResource
        where Name = 'regionjson'

 
Apex: 
<apex:page controller="allObjectListClass">
    <apex:pageBlock>
        <apex:form id = "myForm">
            
            <apex:pageBlockSection>
                <apex:selectList id="objList" value="{!selectedObj}" size="1">
                    <apex:selectOptions value="{!objName}"/>
                    <apex:actionSupport event="onchange" reRender="myForm"/>
                </apex:selectList>  
            </apex:pageBlockSection>
            
            <apex:pageBlockSection>
                <apex:pageblockTable value="{!fieldName}" var="f">
                    <apex:column value="{!f}"/>
                </apex:pageblockTable>
            </apex:pageBlockSection>
            
        </apex:form>        
    </apex:pageBlock>    
</apex:page>
Controller :
public class allObjectListClass {
    public String selectedObj {get;set;}
    
    public static List<selectOption> getObjName(){
        List<selectOption> options = new List<selectOption>();
        
        for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
        {
            Schema.DescribeSObjectResult objResult = o.getDescribe();           
            system.debug( 'Sobject API Name: ' + objResult.getName() +' Sobject Label Name: ' + objResult.getLabel());           
            options.add(new SelectOption(objResult.getName(),objResult.getLabel()));
        }
        return options;
    }
    
    public static List<String> getFieldName(){
        List<String> reqFields = new List<String>();
        /*
			Required Code 
		*/
        return reqFields;
    }
}
I am getting a hard time dealing with schema methods, i have gone through the Salesforce documentation though.
Thanks in advance...


 
I want a list of all Objects in my org and displaying it in a drop down in Visualforce page. The code has compiled but giving unexpected error while getting Preview of VF page.

Controller : 
// Controller
public without sharing class getObjectNamesController {    
    
    public Map<String, Schema.SObjectType> object_Map = Schema.getGlobalDescribe(); 
    public Set<String> objNamesSet = object_Map.keyset();
    
    public List<SelectOption> objNamesList{     
        get{
            Integer i=0;
            for(String myObjName : objNamesSet)
            {
                objNamesList.add(new SelectOption(String.valueOf(i),myObjName)) ; 
                i++;
            } 	    	
            System.debug(objNamesList);   
            return objNamesList ;
        }
        set;
    }
}
VF Page: 
<apex:page controller="getObjectNamesController">
  <apex:form >
      <apex:selectList size="1">
          <apex:selectOptions value="{!objNamesList}"></apex:selectOptions>
      </apex:selectList>
  </apex:form>
</apex:page>
User-added image