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
anup-prakashanup-prakash 

inserting fields in different custom objects after a single insert

Hi I have a Situation here..

 

I have a billing custom object that has a relationship to customer custom object..  and then I have a product custom object and a tempbilling custom object that stores the productID, QTY, Bill ID, customerID..   I have created a visualforce page that allows a person to select a customer and then he selects the products and which is totaled. but I am facing dificulty to manage the databse.. the calulation is working fine but I am facing dificulty to manage the database..

 I want to do is that if I insert into bill the customerID then how can I get the ID of the bill after insert so that I could use it further?

Best Answer chosen by Admin (Salesforce Developers) 
AmitdAmitd

In case of "after insert" you always has the Id field value. So when you insert a bill record then you will get its id in "after insert" event.

 

for(bill__c bl:trigger.new){

bl.id;   // id will be available here

}

 

 

Please mark this soluiton as solved if it has answer to your query.

Kudos

 

Salesforce Developer, Salesforce Administrator

All Answers

Karthikeyan JayabalKarthikeyan Jayabal
AmitdAmitd

In case of "after insert" you always has the Id field value. So when you insert a bill record then you will get its id in "after insert" event.

 

for(bill__c bl:trigger.new){

bl.id;   // id will be available here

}

 

 

Please mark this soluiton as solved if it has answer to your query.

Kudos

 

Salesforce Developer, Salesforce Administrator

This was selected as the best answer
anup-prakashanup-prakash
This is actually what helped.. after I inserted.. I used the Id and it worked perfectly fine. just the way I wanted it to work. Thanks!!