You need to sign in to do that
Don't have an account?
sdjagdja wdguqwe
I have created same fields for Customer and oppertunity object.When i create a new record for customer that fields values should update in Oppertunity also.
I have created same fields for Customer and oppertunity object.When i create a new record for customer that fields values should update in Oppertunity also.For this i have written a trigger between these two objectwith the event after insert, But i am getting error.
Please correct the below code if it is wrong.
trigger updateField on Contact (after insert) {
Set<Id> Ids= new Set<Id>();
for (Contact contact : Trigger.new)
{
Ids.add(customer.Id);
}
List<Contact> contactList = new List<Contact>([Select Id,SMETS_Meter_version__c,Meter_Status__c FromContact where Id in :Ids]);
for(Contact temp : contactList )
{
Oppertunities oppor = new Oppertunities();
oppor.SMETS_Meter_version__c = temp.SMETS_Meter_version__c;
oppor.Meter_Status__c = temp.Meter_Status__c;
insert oppor;
}
}
Please correct the below code if it is wrong.
trigger updateField on Contact (after insert) {
Set<Id> Ids= new Set<Id>();
for (Contact contact : Trigger.new)
{
Ids.add(customer.Id);
}
List<Contact> contactList = new List<Contact>([Select Id,SMETS_Meter_version__c,Meter_Status__c FromContact where Id in :Ids]);
for(Contact temp : contactList )
{
Oppertunities oppor = new Oppertunities();
oppor.SMETS_Meter_version__c = temp.SMETS_Meter_version__c;
oppor.Meter_Status__c = temp.Meter_Status__c;
insert oppor;
}
}
Can you please post the error message that you received?
Thanks,
Vinoth
Please use the below statement which is updated,
Thanks,
Vinoth
Set<Id> Ids= new Set<Id>();
for (Contact contact : Trigger.new)
{
Ids.add(customer.Id);
}
List<Contact> contactList = new List<Contact>([Select Id,First_Name__c, Last_Name_c From Contact where Id in :Ids]);
for(Contact temp : contactList )
{
Opportunity oppor = new Opportunity ();
oppor. First_Name__c c = temp. First_Name__c, __c;
oppor. Last_Name_c = temp. Last_Name_c;
insert oppor;
I have done the modifications still it is showing the error as Error: Compile Error: Variable does not exist: customer.Id at line 5 column 13
for (Contact con : Trigger.new)
{
Ids.add(con.Id);
}
Can you please post the recent code.
Thanks,
Vinoth
trigger updateField on Contact (after insert) {
Set<Id> Ids= new Set<Id>();
for (Contact con : Trigger.new)
{
Ids.add(con.Id);
}
List<Contact> contactList = new List<Contact>([Select Id,Order_Number__c, Amount_c From Contact where Id in :Ids]);
for(Contact temp : contactList )
{
Opportunity oppor = new Opportunity ();
oppor. Order_Number __c = temp. Order_Number __c;
oppor. Amount_c = temp. Amount_c;
insert oppor;
}