• djensen
  • NEWBIE
  • 30 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
Hello - Below is a simple trigger on a contact record that updates a picklist field called Demo Status when a date field called Demo Date is either 1 year or 2 years old. 

Questoin is: How can I get this trigger to automatically update existing contact records when the Demo Date reaches 1 years old? Right now the trigger only updates the field if the contact record is edited.  Looking for something that doesn't require editing to trigger this trigger.

(I am not a developer so hopefully the trigger is written correctly. It does work, but I haven't tested it fully.)

trigger UpdateDemoStatus on Contact (before update)
{
    for (Contact cnts : Trigger.new){
          if (cnts.Demo_Date__c < date.today() - 730) {
            cnts.Demo_Status__c = 'No Demo';
        } else if (cnts.Demo_Date__c < date.today() - 365) {
            cnts.Demo_Status__c = 'Stale';
        } else {cnts.Demo_Status__c = cnts.Demo_Status__c;}
}
}
Hello - I have built a flow that is trigged by a process. The process is setup so that when a task's subject = Email: Course Implementation Summary, the flow changes the opportunity stage to commitment. If I create a New Task or Log a Call using the subject Email: Course Implementation Summary, everything works great. However, if I send an email via task "Send Email', and using the above subject, nothing happens. Any idea why this is? 

Note: I've tried these two subjects: Email: Course Implementation Summary and Course Implementation Summary. (I added Email: since this is automatically added to the subject line when an email is sent.)

Hello, 
I'm hoping someone can help me with this trigger. Here's what it's supposed to do. If notes are added or updated to a text field called "Call Notes" on an opportunity, create a task. This trigger should run when an opp is created or updated.

If I remove "after insert", it seems to work just fine. However, when I add "after insert" I get the error "apex attempt to de-reference a null object: oppNotes".

trigger oppNotes on Opportunity (after insert, after update) {
     List<Task> taskList = new List<Task>();
      for (Opportunity opp : Trigger.new){
        Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
         if (oldOpp.Call_Notes__c != opp.Call_Notes__c ) {
          Task t = new Task();
           t.subject = 'Call Notes';
            t.WhatId = opp.ID;
             t.Status = 'Completed';
            t.Priority = 'Normal';
           t.Type = 'Other';
          t.Description = opp.Call_Notes__c;
         taskList.add(t);
        }
       }
      insert taskList;
     }

Any help would be greatly appreciated. 

I need to map the Primary Contact's last name to a custom text field on the opporunity record. I found the below trigger in a forumn that seems to work -although it maps the contact's full name. Although it maps the name correctly, it now creates an error when converting a lead. Error message below. I'm not a developer and new to triggers so I'm hoping someone can help me with this issue.

1) Can I map just the last name only?
2) Can the lead conversion error be fixed?

Lead Conversion Error:
Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ContactRoleName: execution of BeforeUpdate caused by: System.QueryException: List has no rows for assignment to SObject Trigger.ContactRoleName: line 5, column 1: [] (System Code)

Trigger:
Trigger ContactRoleName on Opportunity(before update)
{OpportunityContactRole Roles = new OpportunityContactRole();
for(Opportunity o:Trigger.new)
{
Roles = [select Id,IsPrimary,Contact.Name, Contact.Email, Contact.Phone from OpportunityContactRole where opportunity.id=:o.Id];
o.Primary_Contact_Name__c = Roles.Contact.Name;
}
}
Hello - Below is a simple trigger on a contact record that updates a picklist field called Demo Status when a date field called Demo Date is either 1 year or 2 years old. 

Questoin is: How can I get this trigger to automatically update existing contact records when the Demo Date reaches 1 years old? Right now the trigger only updates the field if the contact record is edited.  Looking for something that doesn't require editing to trigger this trigger.

(I am not a developer so hopefully the trigger is written correctly. It does work, but I haven't tested it fully.)

trigger UpdateDemoStatus on Contact (before update)
{
    for (Contact cnts : Trigger.new){
          if (cnts.Demo_Date__c < date.today() - 730) {
            cnts.Demo_Status__c = 'No Demo';
        } else if (cnts.Demo_Date__c < date.today() - 365) {
            cnts.Demo_Status__c = 'Stale';
        } else {cnts.Demo_Status__c = cnts.Demo_Status__c;}
}
}
Hello - I have built a flow that is trigged by a process. The process is setup so that when a task's subject = Email: Course Implementation Summary, the flow changes the opportunity stage to commitment. If I create a New Task or Log a Call using the subject Email: Course Implementation Summary, everything works great. However, if I send an email via task "Send Email', and using the above subject, nothing happens. Any idea why this is? 

Note: I've tried these two subjects: Email: Course Implementation Summary and Course Implementation Summary. (I added Email: since this is automatically added to the subject line when an email is sent.)

Hello, 
I'm hoping someone can help me with this trigger. Here's what it's supposed to do. If notes are added or updated to a text field called "Call Notes" on an opportunity, create a task. This trigger should run when an opp is created or updated.

If I remove "after insert", it seems to work just fine. However, when I add "after insert" I get the error "apex attempt to de-reference a null object: oppNotes".

trigger oppNotes on Opportunity (after insert, after update) {
     List<Task> taskList = new List<Task>();
      for (Opportunity opp : Trigger.new){
        Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
         if (oldOpp.Call_Notes__c != opp.Call_Notes__c ) {
          Task t = new Task();
           t.subject = 'Call Notes';
            t.WhatId = opp.ID;
             t.Status = 'Completed';
            t.Priority = 'Normal';
           t.Type = 'Other';
          t.Description = opp.Call_Notes__c;
         taskList.add(t);
        }
       }
      insert taskList;
     }

Any help would be greatly appreciated. 

I need to map the Primary Contact's last name to a custom text field on the opporunity record. I found the below trigger in a forumn that seems to work -although it maps the contact's full name. Although it maps the name correctly, it now creates an error when converting a lead. Error message below. I'm not a developer and new to triggers so I'm hoping someone can help me with this issue.

1) Can I map just the last name only?
2) Can the lead conversion error be fixed?

Lead Conversion Error:
Error: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, ContactRoleName: execution of BeforeUpdate caused by: System.QueryException: List has no rows for assignment to SObject Trigger.ContactRoleName: line 5, column 1: [] (System Code)

Trigger:
Trigger ContactRoleName on Opportunity(before update)
{OpportunityContactRole Roles = new OpportunityContactRole();
for(Opportunity o:Trigger.new)
{
Roles = [select Id,IsPrimary,Contact.Name, Contact.Email, Contact.Phone from OpportunityContactRole where opportunity.id=:o.Id];
o.Primary_Contact_Name__c = Roles.Contact.Name;
}
}