• sdjagdja wdguqwe
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Can anyone help me how to proceed with belo one:

If the contact and opportunity record types are equal,the fields of contact will get autopopulate on opportunity
Below code is to autopopulate the fields from Contact to Oppertunity.

If i change any field value in Opportunity record it should update in Opportunity as well as in Contact
For this i need to proceed with event after update.Can u plz guide me how to proceed with after update event

  List<Opportunity> newOpps = new List<Opportunity>();
  for (Contact con : Trigger.new) {
    Opportunity opp = new Opportunity();
    opp.Name        = con.LastName+' Opportunity';
    opp.StageName   = 'Prospecting';
    opp.Status__c = con.Status__c;
    opp.version__c = con.version__c;
    opp.CloseDate   = Date.today() + 90;
   // opp.AccountId   = acc.Id; // Use the trigger record's ID
    newOpps.add(opp);
  }
  if(newOpps.size()>0)
  insert newOpps;
}
  List<Opportunity> newOpps = new List<Opportunity>();
  for (Contact con : Trigger.new) {
    Opportunity opp = new Opportunity();
    opp.Name        = con.LastName+' Opportunity';
    opp.StageName   = 'Prospecting';
    opp.Status__c = con.Status__c;
    opp.version__c = con.version__c;
    opp.CloseDate   = Date.today() + 90;
   // opp.AccountId   = acc.Id; // Use the trigger record's ID
    newOpps.add(opp);
  }
  if(newOpps.size()>0)
  insert newOpps;
}

 
I'm new to Apex and creating Triggers so hoping someone can help. Here's the scenario;
 
I have created same fields for both contact object and opportunity object. I would like to automatically update the field values on opportunity object whenever I cretae new customer record.
For this I have written the trigger with the event after insert. But I am getting error
Can anyone correct the below code plz….
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,First_name__c, Last_name_c  FromContact where Id in :Ids]);   
       for(Contact temp : contactList )
       {
       Oppertunities oppor = new  Oppertunities();
       oppor.First_Name__c = temp. First_name__c,;
       oppor.Last_Name_c  = Last_name_c;
       insert oppor;
       }
    
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;
       }
     }
I'm new to Apex and creating Triggers so hoping someone can help. Here's the scenario;
 
I have created same fields for both contact object and opportunity object. I would like to automatically update the field values on opportunity object whenever I cretae new customer record.
For this I have written the trigger with the event after insert. But I am getting error
Can anyone correct the below code plz….
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,First_name__c, Last_name_c  FromContact where Id in :Ids]);   
       for(Contact temp : contactList )
       {
       Oppertunities oppor = new  Oppertunities();
       oppor.First_Name__c = temp. First_name__c,;
       oppor.Last_Name_c  = Last_name_c;
       insert oppor;
       }
    
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;
       }
     }