+ Start a Discussion
gv007gv007 

Getting Custom Object id from salesforce sites.

Hi
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.
bob_buzzardbob_buzzard
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 = ' + obj.id);


Dino_Salesforce DeveloperDino_Salesforce Developer
Hi

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

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.

Thanks