• Ember Campbell
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hello!

I've just started to try to use triggers and need some help.  I thought this would be a pretty quick and easy thing to do, but I've been working on this same issue for a while now and I'm at a loss.  I'm including my draft code but it maybe beyond saving.  FYI - I did talk to SF support and found out that they can't help with detailed coding questions like this....  I hoping he community can help me :)

Here is the need: 

Create a new Opportunity when a Contract record is updated, specifically the field named 'Current Term Expiration Date' is updated.

On the new opportunity, I want to prepopulate data from the contract record
  • Record Type = ‘Existing Business’  (01280000000AT8P)
  • Service Offering = Contract field ‘Service_Lines__c’
  • Opportunity name = Create a new opportunity name.
    • Correct format: Dept # – Account Name – Service Line – Renewal (CTE Year)
    • Fields: ‘Department__c’ – ‘Account’ – ‘Service_Lines__c’ – Renewal (Year(‘Current_Term_Expiration_Date__c’)
      • Example for demonstration purposes only   4444 – Houston Methodist Hospital – IONM – Renewal (2014)
  • Stage ‘StageName’= ‘Renewal Notification’
  • Model Type  ‘Model_Type__c’= ‘Renewal’

Here is the code that I commented out – (otherwise I couldn’t save)

// Create the Opportunity record only when CTE is Updated

trigger CreateOpportunity on Contract (after update) {
//List<Opportunity> newOpps = new List <Opportunity>();
//for (Opportunity opp : Trigger.new);
//if (contract.Current_Term_Expiration_Date__c ==isChanged) {
//Opportunity Opp = new Opportunity();   
//opp.Opportunity_Name__c = ‘Department__c’ – ‘Account’ – ‘Service_Lines__c’ – Renewal (Year(‘Current_Term_Expiration_Date__c’)
//opp. RecordType =‘Existing Business’  (01280000000AT8P)
//opp. Service_Line__c=Contract. ‘Service_Lines__c’
//opp. StageName= ‘Renewal Notification’
//opp. Model_Type__c’= ‘Renewal’

}
    // Inserting the New Opportunity Record.

//try {
     //   insert opptoinsert;
  //  } catch (system.Dmlexception e) {
     //   system.debug (e);
   }

Any help would be greatly appreciated
Hello!

I've just started to try to use triggers and need some help.  I thought this would be a pretty quick and easy thing to do, but I've been working on this same issue for a while now and I'm at a loss.  I'm including my draft code but it maybe beyond saving.  FYI - I did talk to SF support and found out that they can't help with detailed coding questions like this....  I hoping he community can help me :)

Here is the need: 

Create a new Opportunity when a Contract record is updated, specifically the field named 'Current Term Expiration Date' is updated.

On the new opportunity, I want to prepopulate data from the contract record
  • Record Type = ‘Existing Business’  (01280000000AT8P)
  • Service Offering = Contract field ‘Service_Lines__c’
  • Opportunity name = Create a new opportunity name.
    • Correct format: Dept # – Account Name – Service Line – Renewal (CTE Year)
    • Fields: ‘Department__c’ – ‘Account’ – ‘Service_Lines__c’ – Renewal (Year(‘Current_Term_Expiration_Date__c’)
      • Example for demonstration purposes only   4444 – Houston Methodist Hospital – IONM – Renewal (2014)
  • Stage ‘StageName’= ‘Renewal Notification’
  • Model Type  ‘Model_Type__c’= ‘Renewal’

Here is the code that I commented out – (otherwise I couldn’t save)

// Create the Opportunity record only when CTE is Updated

trigger CreateOpportunity on Contract (after update) {
//List<Opportunity> newOpps = new List <Opportunity>();
//for (Opportunity opp : Trigger.new);
//if (contract.Current_Term_Expiration_Date__c ==isChanged) {
//Opportunity Opp = new Opportunity();   
//opp.Opportunity_Name__c = ‘Department__c’ – ‘Account’ – ‘Service_Lines__c’ – Renewal (Year(‘Current_Term_Expiration_Date__c’)
//opp. RecordType =‘Existing Business’  (01280000000AT8P)
//opp. Service_Line__c=Contract. ‘Service_Lines__c’
//opp. StageName= ‘Renewal Notification’
//opp. Model_Type__c’= ‘Renewal’

}
    // Inserting the New Opportunity Record.

//try {
     //   insert opptoinsert;
  //  } catch (system.Dmlexception e) {
     //   system.debug (e);
   }

Any help would be greatly appreciated