function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Getting Custom Object id from salesforce sites.

I am using salesforce sites to create records of a custom object from external user.I am using a  controller ,ther user creates serverl objects data ,in the process I need get third object id to perforum the remaining controller logic.what is the best pratice to get object records ids.

First ---User creates Contact information
next custom object
next custom object details in the forms .I need to get third object id ,how do I get it.

Thanks in advance.
If you have inserted a record, you can access the id immediately afterwards, as the platform will set that field value into the instance that you have in your controller, e.g.

MyObject__c obj=new MyObject__c(Name='Test');
insert obj;

// this will display the inserted objects id, as the platform will set that field for you
System.debug('Id = ' +;

Dino_Salesforce DeveloperDino_Salesforce Developer

If you create third object record from your controller then just use that object instance on your page.

public Booking__c b{get; set;}

b = new Booking__c();
b.Name = 'Abc';
insert b;

<apex:outputText value="{!b.Name}" />

If third object record created in system by using trigger on Contact or second object, Then you need to query on third object with respective inserted contact id or second object data. After that queried list u can use on ur vf page.