• Suzanyu
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 34
    Replies
I have here an innerclass with a property that always returns 54. When I try to access the property more than once in a VisualForce Page then I get an unexpected result.

Expected Page Result:
54 - 54

Actual Page Result:
54 -

Notes:
Accessing the property twice in the testmethod works so this makes me think it's a VisualForce issue.

Page:
<apex:page controller="TestPageCon">
{!b.b} - {!b.b}
</apex:page>

Controller:
public class TestPageCon {
public class TestPageCon {
public class B {
public Integer b {
get {return 54;}
}
}

public B getB() {return new B();}

testmethod static void testBug() {
TestPageCon test = new TestPageCon();
System.assertEquals(test.getB().b, 54);
System.assertEquals(test.getB().b, 54);
}
}

Hi Experts,

 

I got a requirement to dynamically create a visualforce page. Details are below

 

Scenario

 

-On one page, there is a list showing all fields Label and Api Name of Sobject. (this part done via describe call)

-User selected some  fields from the list such as Name, Account, Email, Phone...

-The second page will be constructed by selected fields. The difficulty is in this page if a field type is picklist, the picklist will be built up onto the page as well. If the type of field is long textarea, the text input area will show up next to the field name on the page. ETC

-All stuff will be dynamically generated from selected names and their types.

 

Any idea will be great. Many thanks

 

Sue

Hi All,
 
I have an urgent issue. Please give me ideas. Many thanks
 
-- one trigger on account
-- this trigger deployed into producton in a managed package. That means we can not do any modification on that. Even no way to edit "active" checkbox.
-- Code "Schema.getGlobalDescribe().get('Account');" in this trigger
-- when I use apex dataloader mass upload data, an error depressed me
 

caused by: System.Exception: Too many fields describes: 11

I think the Governors and Limits for describe call in trigger allows max no. is 10 as well.  Is that true?????????

-- This trigger calls apex class code. In the apex class code there is a Webservice method callout. In this apex class code, there is a "future" annotation as well. In the apex developer document, governors say

Total number of methods with the future annotation allowed  per Apex invocation7     :   10

Total number of Web service methods allowed :  10

I believe if mass update records number > 10 , those limits will reach and some error  will occur.

-- How can I turn off the trigger in Production which in managed package (released version).

 

Any idea appreciated!!! or Any clarification for that???

Hi All,
 
I have an urgent issue. Please give me ideas. Many thanks
 
-- one trigger on account
-- this trigger deployed into producton in a managed package. That means we can not do any modification on that. Even no way to edit "active" checkbox.
-- Code "Schema.getGlobalDescribe().get('Account');" in this trigger
-- when I use apex dataloader mass upload data, an error depressed me
 

caused by: System.Exception: Too many fields describes: 11

I think the Governors and Limits for describe call in trigger allows max no. is 10 as well.  Is that true?????????

-- This trigger calls apex class code. In the apex class code there is a Webservice method callout. In this apex class code, there is a "future" annotation as well. In the apex developer document, governors say

Total number of methods with the future annotation allowed  per Apex invocation7     :   10

Total number of Web service methods allowed :  10

I believe if mass update records number > 10 , those limits will reach and some error  will occur.

-- How can I turn off the trigger in Production which in managed package (released version).

 

Any idea appreciated!!! or Any clarification for that???

Hi all,
 
I try to uninstall an unmanaged package from a instance. Unfortunately, I got an error like below
Unable to uninstall package
Situation is
In that package, there are some components are used by another component in that package. By that I mean eg. there is a controller which invokes other methods in other apex class. or there are some VF pages which are referenced in this controller.
 
the problem detail like
 
Visualforce PageAddProductsComponent is in use by another component in your organization. AddProductsController
Apex ClassSendConfirmation

Component is in use by another component in your organization. AddProductsController

 

Any idea appreciated

Hi all,
 
 
I got an error
 
Error: List controllers are not supported for OpportunityLineItem

The standardcontroller works for OpportunityLineItem. but once I added recordSetVar, I got the above error. How can I make a list button on product related list against opp. It seems s-control is the only way I can use. I don't want extra custom object for that purpose. So SF guru, do you put any restriction on list controller for opportunitylineitem. if yes, I switch to s-control.

thanks

 

 

 

 Masters,
 
Our client asks us to implement some funtions by using Visualforce.
Any one can tell me whether it is possible to use {!GETRECORDIDS} in VisualForce page. I got a list button which links to a VF page to process selected records. How can I get selected records' Ids ??? or Only scontrol can do that?
 
 
 
Any idea will be great!!
 
Thanks
Hi all,
 
Anyone can tell me the solution on how to pre-populate the contact name in task-mail merge page. The example is from opportunity related list"activty history" users can do mail merge but contact input is blank. My target is to create new button and put URL in it which can pre populate the contact stuff. But unfortunately I failed.
 
Actually I set p3_lkold and p3_lkold, but both did not work.
 
 
Many thanks
 
 
Hi all,
 
 
Could you tell me how I can get the all values or the default value for a picklist type . For example, I have a field named 'Status' with 'Level-1','Level-2' and so on. I want to get these picklist values use Apex code in trigger.
 
Please Please any idea is appreciated. 
 
I try to insert a new opportunity by this way. The account field in opportunity is Lookup type. My code below shows that I got a row for Account but there is nothing in Account Name shown on the page for this opportunity after running this code.
 
Any idea is appreciated.  many thanks
 
Opportunity opp = new Opportunity(Name = 'fromtrigger',Type ='New Customer', Account= [Select Id From Account where name = 'test00'],CloseDate=Date.valueOf('2008-04-28'),StageName='Prospecting'); 
insert opp;
I want to create a new trigger on a specified field(standard, custom).
 
When "status" field in Opportunity is changed or updated the trigger will be fired to modify some information in the correspongding account.
 
How can I deal with it? More tricky for me.
If trigger events can not be applied on the field objects, any other solutions will be appreciated. Thanks 

Hi Experts,

 

I got a requirement to dynamically create a visualforce page. Details are below

 

Scenario

 

-On one page, there is a list showing all fields Label and Api Name of Sobject. (this part done via describe call)

-User selected some  fields from the list such as Name, Account, Email, Phone...

-The second page will be constructed by selected fields. The difficulty is in this page if a field type is picklist, the picklist will be built up onto the page as well. If the type of field is long textarea, the text input area will show up next to the field name on the page. ETC

-All stuff will be dynamically generated from selected names and their types.

 

Any idea will be great. Many thanks

 

Sue

Hi,

I have developed an application which has visualforce pages, apex classes and some custom fields and custom tables.
Now I want to introduce a Namespace prefix for my organization and create a managed package and upload it to Salesforce.

I would appreciate if could get answers to following questions.
1. Do I have to put the namespace prefix for custom fields, tables used in the visualforce, apex classes ?
2. If I do not put namespace prefix for custom fields, tables in the visualforce, apex classes will my managed package work properly when it is installed in another Salesforce organisation.


Thanks
Viraj


  • December 10, 2008
  • Like
  • 0
I have here an innerclass with a property that always returns 54. When I try to access the property more than once in a VisualForce Page then I get an unexpected result.

Expected Page Result:
54 - 54

Actual Page Result:
54 -

Notes:
Accessing the property twice in the testmethod works so this makes me think it's a VisualForce issue.

Page:
<apex:page controller="TestPageCon">
{!b.b} - {!b.b}
</apex:page>

Controller:
public class TestPageCon {
public class TestPageCon {
public class B {
public Integer b {
get {return 54;}
}
}

public B getB() {return new B();}

testmethod static void testBug() {
TestPageCon test = new TestPageCon();
System.assertEquals(test.getB().b, 54);
System.assertEquals(test.getB().b, 54);
}
}
I saw on the Winter ‘09 Developer Screencast a screenshot of a tree conrol. Does anyone know if that code will be released?

I started working on a lazy-loading Flex tree control but don't want to go too far down that road if a Visualforce/Apex version is going to be released.

Flex tree control: http://blog.jeffdouglas.com/2008/12/08/flex-salesforcecom-tree-control/

Jeff Douglas
Informa Plc
blog.jeffdouglas.com
I am trying to create a form that creates a PDF of certatin Opportunity data.  However the first two pieces of data I need on the form are not opporunity data elements.  The first is the name of the actaul SF user creating the PDF i.e., the user's name (Field 1) and the second is today's date (Field 2).  How do I refernce these non opporunity data elements once I set my standardcontroller to "opportunity"?
 
<apex:page Standardcontroller="opportunity" id="{!opportunity.id}" >
  <apex:form >
 
  <table border="0" width="100%" id="table1" cellspacing="0">
    <tr>
        <td width="40%"><b>COMPLETED BY:</b> &nbsp; <apex:outputText value="{Field 1}"> </apex:outputText>  </td>
        <td width="60%"><b>DATE:</b> &nbsp;  <apex:outputText value="{Field 2}"> </td>
    </tr>
    <tr>
       <td width="100%"><b>Opportunity Name:</b> &nbsp; <apex:outputField value="{!opportunity.name}"> </apex:outputField> </td>

  </table>
 
Thanks,
 
Todd B
Good afternoon everyone. I hope someone can point me in the right direction.
 
I'm creating a visual force page that e-mails a 2nd Visualpage rendered in PDF. All that code works fabuliously - but it's been requested that our users can select from a related list the e-mails to send. What I have is a field for "Additional Email Address" and a datatable that displays a related list of "Product Contact Roles" (Basically a object with Contact fields on it).
 
I've managed to get a checkbox in the datatable, I know I can pass e-mail strings by manually typing them in my "Additional Email Address" field - but I"m lost at how do I insert the E-mails listed in the datatable based on the check boxes. I thought of using Onclick or making a button but I'm not quite sure how to actually pass that information.
 
So what is the best option to accomplish this? Do I need to use the check boxes to pass the information to the controller? I assume the onclick option in the inputcheckbox would have to be javascript (which I'm not very familiar with).
 
Here's what I have so far - excuse the messy code I've been going back and forth doing alot of experimentation. Thanks for the help!
 
Page Code:
Code:
<apex:page standardcontroller="Implementation__c" extensions="EmailSentri7StatusController" >
    <apex:form >
        <apex:sectionheader title="Stuff"/>
        <apex:pageblock title="Email" mode="view">            
                <apex:pageblockbuttons location="top">
                    <apex:commandbutton action="{!EmailStatus}" value="Send"/>
                </apex:pageblockbuttons>
            <apex:pageblocksection >
            <!-- Email Address to Send -->
                <apex:pageblocksectionitem >
                    <apex:outputlabel value="Contact Email Address:" for="emailaddressfield">
                    </apex:outputlabel>
                    <apex:inputtext value="{!emailAddress}" id="emailAddressField" size="32"/>
                </apex:pageblocksectionitem>
                <!-- Email for CSS String -->
                <apex:pageblocksectionitem >
                    <apex:outputlabel value="Additional Email Address:" for="Cssaddressfield">
                    </apex:outputlabel>
                    <apex:inputtext value="{!CssAddress}" id="CssAddressField" size="32"/>
                </apex:pageblocksectionitem>
                <!-- This is to add the subject -->
                <apex:pageblocksectionitem >                    
                    <apex:outputlabel value="Email Subject:" for="EmailSubjectField">
                    </apex:outputlabel>
                    <apex:inputtextArea value="{!emailSubject}" id="EmailSubjectField" cols="75" />                    
                </apex:pageblocksectionitem>
                <!-- This is to add the Body -->
                <apex:pageblocksectionitem >                    
                    <apex:outputlabel value="Email Body:" for="EmailBodyField">
                    </apex:outputlabel>
                    <apex:inputtextArea value="{!emailBody}" id="EmailBodyField" cols="75" rows="10"/>                    
                </apex:pageblocksectionitem>
            </apex:pageblocksection>
            <!-- List Product Contact Roles on Implementation -->
            <apex:pageblocksection title="Product Contact Roles" columns="1">
                <apex:datatable value="{!Implementation__c.Product_Contact_Role__r}" var="each" styleclass="list">  
                    <!-- Check box that hopefully has the e-mail as a value - not sure what to use onclick or something else -->
                    <apex:column headervalue="checkbox">
                        <apex:inputCheckbox value="{!each.Contact__r.Email}" />               
                    </apex:column>             
                    <apex:column headervalue="Contact Name" value="{!each.Contact__r.Name}" />
                    <apex:column headervalue="Email" value="{!each.Contact__r.Email}" />
                    <apex:column headervalue="Role" value="{!each.Role__c}" />
                    <apex:column headervalue="Implementer" value="{!each.Implementer__c}" /> 
                </apex:datatable>
               
            </apex:pageblocksection>        
        </apex:pageblock>
 </apex:form>    
</apex:page>

 

And my controller:

Code:
public class EmailSentri7StatusController 
{
    private ApexPages.StandardController controller;
    private String emailAddress;
    private String emailSubject;
    private string emailBody;
    private string cssAddress;
   
    
    public EmailSentri7StatusController(ApexPages.StandardController controller) 
    {
        this.controller = controller;
    }

//Testing used for apex:checkboxes and apex:selectoptions example on page 110
public PageReference test() {
return null;
}
public list<SelectOption> getitems()
{
 list<selectOption> options = new list<selectoption>();
 ID ImplementationId = this.controller.getRecord().id;
 Product_Contact_Role__c[] PCR = [Select p.Contact__r.Email From Product_Contact_Role__c p where p.Implementation__c =:ImplementationId];
 for (integer i=0; i<pcr.size(); i++)
 {
  options.add(new SelectOption(PCR[i].Contact__r.email,PCR[i].Contact__r.email));
 }
 return options;
}
string[] emails = new string[]{};
public string[] getEmails() 
{
 return Emails;
}
Public void setEmails(String[] emails)
{
 this.emails = emails;
}

 //This gets an CSs Address
    public String getCssAddress()
  
    {
        return cssAddress;
    }  

  //this sets the email address found
    public void setCssAddress(String CssAddress)
    {
        this.CssAddress = CssAddress;
    }  
 
   //Dynamic Body Line: This gets an email Subject
    public String getEmailBody()  
    {        
        if(emailBody==null)
        {
      emailBody = 'Please find attached your project status' ;
        }
        return emailBody;
    }
  //this sets the Subject
    public void setEmailBody(String emailBody)
    {
        this.emailBody = emailBody;
    }
  //Dynamic Subject Line: This gets an email Subject
    public String getEmailSubject()  
    {  
        //Build Implementation Object for Subject line
  // ID of the implementation
        ID ImplementationId = this.controller.getRecord().id;
  Implementation__c EmailImplementation = [Select i.Name From Implementation__c i where i.id = :ImplementationId];        
        if(EmailSubject==null)
        {
      EmailSubject = 'Sentri7 Status Update ' + EmailImplementation.Name ;
        }
        return EmailSubject;
    }
  //this sets the Subject
    public void setEmailSubject(String emailSubject)
    {
        this.emailSubject = emailSubject;
    }
     
  //This gets an email Address
    public String getEmailAddress()
  
    {
     //Set EmailAddress if Null in visualforce page S7Emailtest
        if(emailAddress==null)
        {
         
         //This was my test to send to me
      Contact EmailContact =[Select c.Email From Contact c where c.id = '0035000000O12Zo'];
      emailaddress =  EmailContact.Email;
        }

        return emailAddress;
    }
  

  //this sets the email address found
    public void setEmailAddress(String emailAddress)
    {
        this.emailAddress = emailAddress;
    }
    
    public PageReference emailStatus()
    {
        // ID of the implementation
        ID ImplementationId = this.controller.getRecord().id;
        //Build Contact Object 
           Contact EmailContact =[Select c.id From Contact c where c.email = :emailAddress];
        
        // Retrieve the PDF as a Blob from the Visualforce page
        PageReference S7Email = Page.S7Email;
        S7Email.getParameters().put('id', ImplementationId);
        Blob pdf = s7Email.getContent();    
      
        // Create the email to send to client
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();        
       
        //set email that's provided
        mail.setToAddresses( new String[] {emailAddress});
        
        //SET SUBJECT LINE        
        //OriginalCode: mail.setSubject('Sentri7 Status Update ' + EmailImplementation.Name);
        mail.setSubject(emailSubject);
        
        //Set BODY
        //Original Code: mail.setPlainTextBody('Please find attached your project status');      
        //mail.setHtmlBody('this works but not s7email');    
        mail.setPlainTextBody(emailBody);
        
        //set Attachment   
        Messaging.EmailFileAttachment mailAttachment;
        mailAttachment = new Messaging.EmailFileAttachment();
        mailAttachment.setFileName('Sentri7Status.pdf');
        mailAttachment.setBody(pdf);
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { mailAttachment });
        
        //Set cc email removed
        mail.setCcAddresses(new string[] {'FILL with CssEmails'});
        //Set BCC email removed
        mail.setBccAddresses(new string[] {'bcc email'});
        
        //save as activity
        mail.setTargetObjectId(EmailContact.Id);
        mail.setWhatId(ImplementationId);
        mail.setSaveAsActivity(true);
       
        // Send the email
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        
        return ApexPages.currentPage();
        //test to return the attachment
        //return s7Email;      
    }
}


 

 


Folks,
I am developing a VF page, where I render a task list on a pageBlockTable. Now on the pageBlockTable, apart from the standard task fields, I also have a field called 'Day' that will display the english day of the activityDate (like Thu or Fri or..) .. Below is my current code:

                    <apex:pageBlockTable value="{!dataTabTasks}" var="task" cellspacing="4" id="taskTable">
                        <apex:column >
                            <apex:facet name="header">Action</apex:facet>
                               <a href="#" onclick="delTask('{!task.Id}','{!$Component.theHiddenInput}');"><b>Del</b></a>
                       </apex:column>
                        <apex:column >
                            <apex:facet name="header">Comment</apex:facet>
                            <a href="#"> <apex:image url="{!$Resource.addComment_img}" styleClass="toggleArrow toggleArrowCollapsedEmpty;" alt="Expand" title="Expand"
                              onclick="toggleFieldEdit('{!$Component.pg1}','{!$Component.pg2}');"/></a>
                       </apex:column>
                       <apex:column >                  
                            <apex:facet name="header">Task Subject</apex:facet>
                            <apex:inputfield id="subject" value="{!task.subject}" required="true" style="width: 110px;"/>
                            <apex:panelGrid columns="1" id="pg1" style="display: none;">
                                <apex:facet name="header"><b>Comments</b></apex:facet>
                                <apex:inputText id="description" value="{!task.description}" maxlength="2000" style="width: 160px; height: 40px;word-wrap: break-word "/>
                            </apex:panelGrid>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Day</apex:facet>
                            <apex:outputText id="day_id" style="width: 40px;font-weight: bold;" value="{??}"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Due Date</apex:facet>
                            <apex:inputfield id="activityDate" value="{!task.activityDate}" />        
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Assigned To</apex:facet>
                            <apex:inputfield id="ownerid" value="{!task.ownerid}" style="width: 110px;"/>
                            <apex:panelGrid columns="2" id="pg2" style="display: none;">
                                <apex:facet name="header"><b>Reminder</b></apex:facet>
                                <apex:inputfield id="reminderChkBox_id" value="{!task.IsReminderSet}"/>
                                <apex:inputfield id="reminder" value="{!task.ReminderDateTime}" style="width: 110px;"/>
                             </apex:panelGrid>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Type</apex:facet>
                            <apex:inputfield id="type" value="{!task.type}" style="width: 110px;"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Priority</apex:facet>
                            <apex:inputfield id="priority" value="{!task.priority}" required="false" style="width: 110px;"/>
                        </apex:column>
                        <apex:column >
                            <apex:facet name="header">Status</apex:facet>
                            <apex:inputfield id="status" value="{!task.status}" required="false" style="width: 110px;"/>
                        </apex:column>                   
                    </apex:pageBlockTable>

My problem is with the line highlighted in Red.<apex:outputText id="day_id" style="width: 40px;font-weight: bold;" value="{??}"/>; Now is there a way to load the 'day' of the activity based on the activityDate when the pageBlockTable is rendered.  day is not part of the standard Task Object fields and hence we need to calculate it manually. But not sure when / how / where to do this calculation.

Your help will be highly appreciated !!
I have built a custom object similar to campaign say "A" and also built a junction object which links object A and contacts. Next i built a two page wizard to mass add selected contacts into the junction object. In the first page of wizard i select the name and status and in the second page i need to display a list of contacts with their name and a checkbox. So when i select a few checkboxes to choose contacts and click a button to add those contacts into my junction object.

I need a sample code of how to display a list of contacts with checkboxes and sample code of how to add the selected contacts into the juction object. Plz help me...
  • December 07, 2008
  • Like
  • 0
Hi All,
 
I have an urgent issue. Please give me ideas. Many thanks
 
-- one trigger on account
-- this trigger deployed into producton in a managed package. That means we can not do any modification on that. Even no way to edit "active" checkbox.
-- Code "Schema.getGlobalDescribe().get('Account');" in this trigger
-- when I use apex dataloader mass upload data, an error depressed me
 

caused by: System.Exception: Too many fields describes: 11

I think the Governors and Limits for describe call in trigger allows max no. is 10 as well.  Is that true?????????

-- This trigger calls apex class code. In the apex class code there is a Webservice method callout. In this apex class code, there is a "future" annotation as well. In the apex developer document, governors say

Total number of methods with the future annotation allowed  per Apex invocation7     :   10

Total number of Web service methods allowed :  10

I believe if mass update records number > 10 , those limits will reach and some error  will occur.

-- How can I turn off the trigger in Production which in managed package (released version).

 

Any idea appreciated!!! or Any clarification for that???

The StandardSetController (or Database.QueryLocator) ignores the SOQL 'where' clause.

Because QueryLocator can only be used with StandardSetController or in managed sharing recalc, I can't test the it separately to see exactly where the bug lies.

This (simplified) example shows the bug in the StandardSetController context.

I have a custom visualforce page that lists users:

Code:
<apex:page controller="CtlBugPgr" title="Bug">
<apex:form>

<apex:pageBlock title="Users" id="UserList">

<apex:pageBlockTable value="{!data}" var="each">
  <apex:column headerValue="Active?">{!each.IsActive}</apex:column>
  <apex:column headerValue="User">{!each.Name}</apex:column>
  <apex:column headerValue="UserType">{!each.UserType}</apex:column>
</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>
</apex:page>

 The controller for this page uses StandardSetController:

Code:
public class CtlBugPgr {

  //-------------------------------------------------------------------------------
  // User List
  //-------------------------------------------------------------------------------
  public User[] data { get { return (List<User>)pgr.getRecords(); } set; }

  public ApexPages.StandardSetController pgr {
    get {
      if (pgr == null) pgr = initPager();
      return pgr;
      }
    set;
    }
  
  //-------------------------------------------------------------------------------
  // privates
  //-------------------------------------------------------------------------------
  private ApexPages.StandardSetController initPager() {
    ApexPages.StandardSetController ret = new ApexPages.StandardSetController(Database.getQueryLocator(
[select Name, UserType, IsActive from User where IsActive = true and UserType = 'Standard']
));
ret.setPageSize(10); // UPDATED: necessary to reproduce bug!
return ret;
} }

 
Note the two conditions in the where clause of the SOQL.

If I run the query directly via "executeAnonymous" I get what I expect:

Code:
> System.debug([select Name, IsActive, UserType from User where IsActive = true and UserType = 'Standard']);

20081125225927.981:AnonymousBlock.i: line 1, column 1: ( User:{UserType=Standard, IsActive=true, Name=John Hart, Id=...})

 
However, in the visualforce page, all Users are returned:






Message Edited by jhart on 11-26-2008 03:25 PM
  • November 25, 2008
  • Like
  • 0
I don't know it is possible , but here we goes:

I want to build a form to edit a Standard Object, into a custom visualforce page.

To do that , i get the description of every field (with the getDescribe() and things like this), and i put it on a list.

The apex code:

Code:
The class:

 public class AccountEditableField {
  public String label { get; set;}
  public Schema.SObjectField value { get; set; }
 }

The Parser:

 public void accountDescribe(){
 
  Set <String> fieldKeys = new Set<String>();
   
  fieldKeys = AccountFieldsDescribe.keySet();
 
  List <String> editableFieldKeys =  new List<String>();
 
  String queryFields = '';
 
  for(String elem:fieldKeys){
   // Get the fields
   Schema.DescribeFieldResult field = (AccountFieldsDescribe.get(elem)).getDescribe();
    
   //Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.elem;
   if(field.isAccessible() && field.isUpdateable()){
    editableFieldKeys.add(elem);
    queryFields += field.getSObjectField()+', ';    
   }
       
   System.Debug(' ** \n'+AccountFieldsDescribe.get(elem)+'\n ** \n The field is visible (accesible)—:'+field.isAccessible()+' \n **  \n The field is Updateable–:'+field.isUpdateable());   
  }
   
  queryFields = queryFields.substring(0,queryFields.length() - 2);
    
 
  for(String f:editableFieldKeys){
   
   AccountEditableField fieldEditable = new AccountEditableField();
   Schema.DescribeFieldResult fieldDescribed = (AccountFieldsDescribe.get(f)).getDescribe();
   
   fieldEditable.label = fieldDescribed.getLabel();
   fieldEditable.value = fieldDescribed.getSObjectField();
   
   listOfFields.add(fieldEditable);
 
  }
 
 }

 



And try to generate the form at at the visualforce page:

Code:
 <apex:form id="accountEdition">
   <apex:repeat value="{!listOfFields}" var="field">
    <apex:outputText value="{!field.label}" />
    <apex:inputField value="{!field.value}" />
   </apex:repeat>
 </apex:form> 

 When i try to save the page, the error are:

Save error: Could not resolve the entity from <apex:inputField> value binding '{!field.value}'.  inputField can only be used with SObject fields

I know that the code at the apex controller can be simplified but i keep it in that way to make it easy to understand.

Anybody knows a workaround for that problem ?
Another way to build a dynamic form ?


Thanks in advance ;)


Message Edited by Br1 on 11-05-2008 12:15 PM
  • November 05, 2008
  • Like
  • 0