You need to sign in to do that
Don't have an account?
Sweta jain
Insert Contact Fields on another record before insert
I am having 3 objects
1 contact (Standard Object)
2 Banking
3 Customer
Banking is having lookup of contact
Customer is having lookup of Banking
I have this trigger to insert a customer record as a banking record is created
Now i want to insert the values of standard field on contact ( related to Banking via lookup ) into text fields of Customer record on insert
like Customer.First_name__c = Contact.first name
Please suggest
trigger Banking_PopulatecustomerRecord on Banking__c (after insert){
Set<Id> IdSet = new Set<Id>();
for(Banking__c mp:trigger.new)
IdSet.add(mp.Id);
List<Customer __c> BankingstubToCreate = new List<Customer __c>();
for(Banking__c mp:trigger.new)
{
if(IdSet.size()>0 )
{
Customer __c s = new Customer __c();
s.Banking__c =mp.Id ;
mccystubToCreate.add(s);
}
}
if(BankingstubToCreate.size()>0)
{
Database.SaveResult[] lsr = Database.insert( BankingtubToCreate, false);
//insert finalCreateListOfStub
}
}
1 contact (Standard Object)
2 Banking
3 Customer
Banking is having lookup of contact
Customer is having lookup of Banking
I have this trigger to insert a customer record as a banking record is created
Now i want to insert the values of standard field on contact ( related to Banking via lookup ) into text fields of Customer record on insert
like Customer.First_name__c = Contact.first name
Please suggest
trigger Banking_PopulatecustomerRecord on Banking__c (after insert){
Set<Id> IdSet = new Set<Id>();
for(Banking__c mp:trigger.new)
IdSet.add(mp.Id);
List<Customer __c> BankingstubToCreate = new List<Customer __c>();
for(Banking__c mp:trigger.new)
{
if(IdSet.size()>0 )
{
Customer __c s = new Customer __c();
s.Banking__c =mp.Id ;
mccystubToCreate.add(s);
}
}
if(BankingstubToCreate.size()>0)
{
Database.SaveResult[] lsr = Database.insert( BankingtubToCreate, false);
//insert finalCreateListOfStub
}
}
What is mccystubToCreate.
I think you have to write there BankingstubToCreate insted of mccystubToCreate.
Try this .
it'll work.
And on more thing If you want to insert many fields not only Banking field in Customer object then you have to write them.
like
Regards
Virendra
But you mean to say
s.first_name__c = mp.contact__r.firstname
I tried the same but it is not working , Do i have to query fields from contact ?
Change it accordng to your fieldname i worte it in general
But i dont wanna populate fields from banking into customer , your idea is ok for the
But i need to update fields from conact to customer and contact is lookup on banking , so we have to quesy fields from contact
i hope this is helpful for you.
Here ClassA__C is your Banking__c.
And Object_A__c is Customer__c.
Kind regards
Virendra