• Roadie
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies

Hi, I'm attempting to pull the default value of a field (picklist) out using a metadata call. A simple example of what isn't working is below. The debug statement yields "null." This code works fine if one is trying to find the Label on the field or some other attributes of the field, but not the default value (and, I verified that the default value is set for this picklist named 'Type' on the account object).

 

Code:
Account a = new Account();
Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Type;
f = f.getSObjectField().getDescribe();
System.debug('Default Value is: ' + f.getDefaultValue());

Thank you!
 

  • December 06, 2008
  • Like
  • 0
Hi, I'm having issues with the SelectList and setting multiselect to false. To test things out, I tried reverting back to the sample code listed in the cookbook (code below). The only thing (I think) that I changed is the multiselect="true" to multiselect="false" in the Visualforce code below. When the user selects a country and clicks the "Test" button, the name of the country is not displayed on the screen as it should. Also, the debug log shows the following: 
 
15:19:14 DEBUG - ***Begining Page Log for /apexpages/devmode/developerModeContainer.apexpj_id0:j_id1:j_id2: An error occurred when processing your submitted information.
 
Any thoughts? Thanks!
 
Code:
<apex:page controller="samplecon">
        <apex:form >
                <apex:selectList value="{!countries}" multiselect="false">
                        <apex:selectOptions value="{!items}"/>
                </apex:selectList><p/>
                <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
        </apex:form>
        <apex:outputPanel id="out">
                <apex:actionstatus id="status" startText="testing...">
                        <apex:facet name="stop">
                                <apex:outputPanel >
                                        <p>You have selected:</p>
                                        <apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
                                </apex:outputPanel>
                        </apex:facet>
                </apex:actionstatus>
        </apex:outputPanel>
  </apex:page>

 
Code:
public class samplecon {
        String[] countries = new String[]{};
        public PageReference test() {
                return null;
        }
        public List<SelectOption> getItems() {
                List<SelectOption> options = new List<SelectOption>();
                options.add(new SelectOption('US','US'));
                options.add(new SelectOption('CANADA','Canada'));
                options.add(new SelectOption('MEXICO','Mexico'));
                return options;
        }
        public String[] getCountries() {
             return countries;
        }
        public void setCountries(String[] countries) {
                this.countries = countries;
        }
  
  }
  • November 17, 2008
  • Like
  • 0
Hi all:
   My scenario:
              A user clicks on a new button that would take the necessary info from account record and place it into the edit page of the custom object filling in all the fields necessary from the Account record selected.
  1. Do I have to re-create the page in VF in edit mode ? If yes, then does anyone know how to create two columns and mock up the page directly the same as the edit page for that object???
  2. Can I link to the edit mode of the Page and do it that way?
  3. Does anyone have an example of this please...
Thanks

Hi, I'm attempting to pull the default value of a field (picklist) out using a metadata call. A simple example of what isn't working is below. The debug statement yields "null." This code works fine if one is trying to find the Label on the field or some other attributes of the field, but not the default value (and, I verified that the default value is set for this picklist named 'Type' on the account object).

 

Code:
Account a = new Account();
Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Type;
f = f.getSObjectField().getDescribe();
System.debug('Default Value is: ' + f.getDefaultValue());

Thank you!
 

  • December 06, 2008
  • Like
  • 0
Hi, I'm having issues with the SelectList and setting multiselect to false. To test things out, I tried reverting back to the sample code listed in the cookbook (code below). The only thing (I think) that I changed is the multiselect="true" to multiselect="false" in the Visualforce code below. When the user selects a country and clicks the "Test" button, the name of the country is not displayed on the screen as it should. Also, the debug log shows the following: 
 
15:19:14 DEBUG - ***Begining Page Log for /apexpages/devmode/developerModeContainer.apexpj_id0:j_id1:j_id2: An error occurred when processing your submitted information.
 
Any thoughts? Thanks!
 
Code:
<apex:page controller="samplecon">
        <apex:form >
                <apex:selectList value="{!countries}" multiselect="false">
                        <apex:selectOptions value="{!items}"/>
                </apex:selectList><p/>
                <apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
        </apex:form>
        <apex:outputPanel id="out">
                <apex:actionstatus id="status" startText="testing...">
                        <apex:facet name="stop">
                                <apex:outputPanel >
                                        <p>You have selected:</p>
                                        <apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
                                </apex:outputPanel>
                        </apex:facet>
                </apex:actionstatus>
        </apex:outputPanel>
  </apex:page>

 
Code:
public class samplecon {
        String[] countries = new String[]{};
        public PageReference test() {
                return null;
        }
        public List<SelectOption> getItems() {
                List<SelectOption> options = new List<SelectOption>();
                options.add(new SelectOption('US','US'));
                options.add(new SelectOption('CANADA','Canada'));
                options.add(new SelectOption('MEXICO','Mexico'));
                return options;
        }
        public String[] getCountries() {
             return countries;
        }
        public void setCountries(String[] countries) {
                this.countries = countries;
        }
  
  }
  • November 17, 2008
  • Like
  • 0