+ Start a Discussion
TonyPhamTonyPham 

Can I write down my own objects?

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

 


Best Answer chosen by Admin (Salesforce Developers) 
Tarun Khatri (TK)Tarun Khatri (TK)

Hi,

 

You can use Custom object for your application. You can create more than one custom field per object (Limit of Custom field depends upon your Edition).

 

Steps:
Go to Setup > Create > Objects > (Your Object).
Go to 'Custom Fields & Relationships' section and click 'New'.

 

By this way you can create more custom fields.

All Answers

sfdcfoxsfdcfox

Consider a custom object, or, alternatively, a record type in leads. Both should offer a venue for the functionality that you seek.

TonyPhamTonyPham

Thank you for the answer.

 

I am still confused. From the tutor document (Virtualforce one), I see that it seems to allow building a custom object from standard objecs only - it means I have to use combinations of standard objects but can not use any thing which is simpler (e.g. fewer fields) than standard ones.

 

Am I missing some thing? Thanks.

 

/tony

skk169skk169

Why coding? create an custom object with clicks: App setup>create>Objects>new    and give watever fields u require. or u can hide unwanted standard  fields from standard object by using page layouts.

TonyPhamTonyPham

Thanks for helps.

 

Still problems:

- I have tried Object. However, it allows me to create only one data field for each new object. Thus to have enought fields for managing a peson data (firstName, lastName, email, companyName...) I have to create many objects to keep those information for one record (of one person). It seems to be complicated to manage them (how to know which one from a record, how to retrive them for a given person ID...)

 

In brief, my question: do you think Object is a good solution for my case (managing person data)?

 

- Using standard objects will be my last attempt if I can not find out any solution for having a "simpler object" than standard one.

 

Thanks

Tarun Khatri (TK)Tarun Khatri (TK)

Hi,

 

You can use Custom object for your application. You can create more than one custom field per object (Limit of Custom field depends upon your Edition).

 

Steps:
Go to Setup > Create > Objects > (Your Object).
Go to 'Custom Fields & Relationships' section and click 'New'.

 

By this way you can create more custom fields.

This was selected as the best answer
TonyPhamTonyPham

Thank you so much. It seems be a solution / answer for my first concerning. Will read and work more with custom objects.