• TonyPham
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies

Hi all,

 

I need to create my own object, named thePeople with some basic fields such as firstName, lastName, email, company... By copying and modifying sample codes, I can create a form in Visualforce to enter data and then write down information of my object to server via Lead object, using Apex code. The Apex code looks like:

 

public class thePeople {

            private String firstName;
            private String lastName;
            private String company;
            private String email;
		...
            public PageReference save() {
                PageReference p = null;
                try {
                        Lead newlead = new Lead(LastName=this.lastName, 
                                                FirstName=this.firstName, 
                                                Company=this.company, 
                                                Email=this.email);
                        insert newlead;
                 } catch (Exception e) {
                        p = Page.failure;
                        p.getParameters().put('error', 'noInsert');
                 }
                
                if (p == null) {
                    p = Page.success;
                }
                
                p.setRedirect(true);
                return p;
            }
}

 

However, Lead object seems to be too redundant and heavy one to me. Furthermore, I don't want all information of my object can be seen in Lead tab. 

 

Thus my (first) question: can I write and read my own object only with only few fields instead of using standard ones? If yes, how (please give me a sample)?

 

Thanks in advance for any helps.

 

Tony

 


Hi all,

 

I need to create my own object, named thePeople with some basic fields such as firstName, lastName, email, company... By copying and modifying sample codes, I can create a form in Visualforce to enter data and then write down information of my object to server via Lead object, using Apex code. The Apex code looks like:

 

public class thePeople {

            private String firstName;
            private String lastName;
            private String company;
            private String email;
		...
            public PageReference save() {
                PageReference p = null;
                try {
                        Lead newlead = new Lead(LastName=this.lastName, 
                                                FirstName=this.firstName, 
                                                Company=this.company, 
                                                Email=this.email);
                        insert newlead;
                 } catch (Exception e) {
                        p = Page.failure;
                        p.getParameters().put('error', 'noInsert');
                 }
                
                if (p == null) {
                    p = Page.success;
                }
                
                p.setRedirect(true);
                return p;
            }
}

 

However, Lead object seems to be too redundant and heavy one to me. Furthermore, I don't want all information of my object can be seen in Lead tab. 

 

Thus my (first) question: can I write and read my own object only with only few fields instead of using standard ones? If yes, how (please give me a sample)?

 

Thanks in advance for any helps.

 

Tony