You need to sign in to do that
Don't have an account?
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?
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
You can try the below sample code from Apex doc:
Creating Parent and Child Records in a Single Statement Using Foreign Keys
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