• SeanSee
  • NEWBIE
  • 0 Points
  • Member since 2010

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

I am trying to pull a custom field in an event into a custom field in the campaign that the event is related to.   The trigger seems to be saving without any errors but it's not working the way I would expect it to.  The code I'm using is:

 

trigger SetiLinkURLinCampaign on Campaign (before insert, before update){ 

 

    Campaign[]  triggerBatch = Trigger.new;

 

    // List of Campaign IDs

    List<String> cmpgnIDs = new List<String>();

 

    for(Campaign c:triggerBatch){

        cmpgnIDs.add(c.id); // Adding CampaignId to List

 

    } 

 

    // Event Map

    Map<ID, Event> eventMap = new Map<ID, Event>([select id, OwnerId, ILNC_sf__iLincJoinURL__c from Event where Id = :cmpgnIDs]);

 

 

    for(Campaign c:triggerBatch){

 

       if(eventMap.containsKey(c.Id)){

           Event campaign = eventMap.get(c.Id) ;      

           c.iLinc_Join_URL__C = campaign.ILNC_sf__iLincJoinURL__c;

 

       }   

 

    }

 

}

 

Any help would be greatly appriciated.

 

Thanks,


Sean

I'm trying to create a trigger that will update a custom object that we have called a participant record anytime a user submits a cancellation case.  The problem I'm running into is that we also use a custom object called programs and we've made a change so that multiple records use the same name.  I am trying to use an if else statement and the division to differentiate the different program names.

 

Right now the trigger is not getting to the end to update the participant record but I'm not sure why.  If anyone has any suggestions it would be a huge help.

 

trigger CancellationCaseTrigger on Case (before insert, before update) {
    for (Case thiscase: System.Trigger.new) {
    
       
        // DE-6 : Modifed Orignal Trigger to Only Cancel the Program specified on the Case Object
        Participant__c[] Participants = [Select Id from Participant__c WHERE Account_del__c = :thiscase.AccountId AND Program__C = :progORsvc.id  ];
        
        for (Participant__c p : Participants) {
            p.Cancellation_Case__c = thiscase.Id;
            p.Program_Status__c = 'Cancelled';
            p.Cancel_Date__c =  thiscase.Program_End_Date__c;
            p.Enrolled__c = 'No';
            
            update p;
        }
    }
    }
}}}}}}

 

I'm trying to write a workflow rule formula that will allow me to check if a custom field has been changed and if one of a list of users is the account coordinator.  It seems like it should work but it's not triggering the workflow rule.  What I have now is:

 

AND( 
OR( 
Account_Coordinator__c = "meghan Buster", 
Account_Coordinator__c = "Sarah Isley", 
Account_Coordinator__c = "Tammy Rackard", 
Account_Coordinator__c = "Sean Carr", 
Account_Coordinator__c = "Teresa Wells" ), 
ISCHANGED( Drop_Date_Change_Description__c))

 

If anyone could provide some advice it would be much appreciated.

 

Thanks,


Sean

I am trying to write a validation rule that will prevent users from going back to 'Sent' as a campaign member status.  I have rule but it is preventing the status from changing From 'Sent' and I need it to prevent users from going back to 'Sent'.  Can anyone please help.  The code is below

 

AND(ISCHANGED(Status),
NOT(ISPICKVAL(Status,"Sent")))

 

Thanks,


Sean

I am trying to find a way to use a merge field in an HTML template to create a hyperlink.  We have a formula field in a campaign member record that will create a hyperlink to a webform.  However we want to be able to use a merge field in a custom HTML template that is not from a letterhead and have it display in the email as a hyperlink.  Is there a way to accomplish this?

I am trying to customize the email opt out app in order to update a custom field HasOptOutCampaign__c which has been created on both the lead and contact objects.  Everything appears to be correct and I did not receive any error when saving this code but when I try to create an email service I receive the following error message:

 

  • The Apex Class selected is not valid. An Apex Class that implements the Messaging.InboundEmailHandler interface must be selected.

Does anyone know how I might be able to correct this?  I will paste the code below.

 

Thanks so much.

 

Global class optOutCampaign implements Messaging.inboundEmailHandler{

Global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
                            Messaging.InboundEnvelope env ) {

// Create an inboundEmailResult object for returning
//the result of the Apex Email Service
Messaging.InboundEmailResult result = new Messaging.InboundEmailResult();
 
// Contact and Lead lists to hold all the updated records
List<Contact> lc = new List <contact>();
List<Lead> ll = new List <lead>();
 
// Convert the subject line to lower case, so I can match on lower case
String mySubject = email.subject.toLowerCase();
// String I am searching for in the subject line
String s = 'campaign opt out';
 
// Check variable to see if the words "campaign opt out" were found in the subject line
Boolean unsubMe;
// Look for the unsubcribe word in the subject line,
// if it is found return true, otherwise false is returned
unsubMe = mySubject.contains(s);
 
 // If unsubscribe is found in the subject line enter the if statement
 
 if (unsubMe == true) {
    
    try {
        
    // Lookup all contacts with a matching email address
        
     for (Contact c : [Select Id, Name, Email, HasOptOutCampaign__c
                        From Contact
                        Where Email = :env.fromAddress
                        And HasOptOutCampaign__c = false
                        Limit 100]) {
                        
        // Add all the contacts into the List   
                            c.HasOptOutCampaign__c = true;
                            lc.add(c);                                 
    }    
        // update all the Contact records
        
        update lc;
            }
    catch (System.QueryException e) {
        System.debug('Contact Query Issue: ' + e);
        }   

    try {
        // Lookup all leads matching the email address
     for (Lead l : [Select Id, Name, Email, HasOptOutCampaign__c
                        From Lead
                        Where Email = :env.fromAddress
                        And isConverted = false
                        And HasOptOutCampaign__c = false
                        Limit 100]) {
        // Add all the leads to the List        
        l.HasOptOutCampaign__c = true;
        ll.add(l);
                               
           System.debug('Lead Object: ' + l);   
    }    
        // Update all Lead records in the query
        update ll;
            }

    catch (System.QueryException e) {
        System.debug('Lead Query Issue: ' + e);
        }   

    System.debug('Found the campaign opt out word in the subject line.');
 }
 else {
    System.debug('No Campaign Opt out word found in the subject line.' );
 }
// Return true and exit
// True will confirm it is complete and no bounced email
// should be send the sender of the unsubscribe request.
result.success = true;
return result;
    }   
    
    // Test method to ensure you have enough code coverage
    // Have created two methods, one that does the testing
    // with a valid "unsubcribe" in the subject line
    // and one the does not contain "unsubscribe" in the
    // subject line
    
static testMethod void testoptoutcampaign() {

// Create a new email and envelope object
   Messaging.InboundEmail email = new Messaging.InboundEmail() ;
   Messaging.InboundEnvelope env    = new Messaging.InboundEnvelope();

// Create a new test Lead and insert it in the Test Method        
   Lead l = new lead(firstName='Rasmus',
            lastName='Mencke',
            Company='Salesforce',
            Email='rmencke@salesforce.com',
            HasOptOutCampaign__c=false);
   insert l;

// Create a new test Contact and insert it in the Test Method  
   Contact c = new Contact(firstName='Rasmus',
                lastName='Mencke',
                Email='rmencke@salesforce.com',
                HasOptOutCampaign__c=false);
   insert c;
   
   // test with subject that matches the unsubscribe statement
   email.subject = 'test campaign opt out test';
   env.fromAddress = 'rmencke@salesforce.com';
   
   // call the class and test it with the data in the testMethod
   optoutcampaign optoutcampaignObj = new optoutcampaign();
   optoutcampaignObj.handleInboundEmail(email, env );
                        
   }
 
static testMethod void testUnsubscribe2() {

// Create a new email and envelope object
   Messaging.InboundEmail email = new Messaging.InboundEmail();
   Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();

// Create a new test Lead and insert it in the Test Method        
   Lead l = new lead(firstName='Rasmus',
            lastName='Mencke',
            Company='Salesforce',
            Email='rmencke@salesforce.com',
            HasOptOutCampaign__c=false);
   insert l;

// Create a new test Contact and insert it in the Test Method    
   Contact c = new Contact(firstName='Rasmus',
                lastName='Mencke',
                Email='rmencke@salesforce.com',
                HasOptOutCampaign__c=false);
   insert c;
   
   // Test with a subject that does Not contain campaign opt out
   email.subject = 'test';
   env.fromAddress = 'rmencke@salesforce.com';

   // call the class and test it with the data in the testMethod
   optoutcampaign optoutcampaignObj = new optoutcampaign();
   optoutcampaignObj.handleInboundEmail (email, env);                      
   }    
   
}

I have created a VisualForce page that I would like to use on a custom object I've built.  I am trying to set it so that whenever someone enters a new record or whenever a record is edited, the new VisualForce page with graphics will display.  On the page I have it set to use the Custom Accountability controller with:

 

 

<apex:page standardController="Accountability__c"   RecordSetVar="Accountability">
<apex:variable value="{!Accountability__c}" var="acc"/> 
    <apex:form >

 

<apex:page standardController="Accountability__c" RecordSetVar="Accountability">

<apex:variable value="{!Accountability__c}" var="acc"/>     

<apex:form >

 

Can anyone please tell me what I am doing wrong and I how I can over ride the standard view with my custom one.

 

Thanks so much,

 

Sean

I have written a custom Apex Class that I am using to create a Completed Task for our inside sales people to log a call without having to enter any notes.  It works perfectly except for one small problem.  The tasks that are created are all being assigned a CreatedDate or 1/1/1900.

 

I tried adding objTask.CreatedDate = System.Now(); but I am getting an error that says the field is not writeable.  Is there another way to pass the datetime information to the CreatedDate field?

 

The full code is:

 

public with sharing class LogCall {

    public String AccountID;
    
    public Id TaskRecordTypeId;
    
    public LogCall() {
    
        if(ApexPages.currentPage().getParameters().get('id') != null){        
           AccountID = ApexPages.currentPage().getParameters().get('id');           
           for(RecordType rt : [SELECT ID FROM RecordType WHERE sObjectType = 'Task' AND Name = 'Log a call' Limit 1]){
              TaskRecordTypeId = rt.Id;
           }
           
        }
    }
    
    public PageReference CreateNewTask(){      
        Pagereference  pr = null;        
        try{
            
            Task objTask = new Task();
            
            objTask.CreatedDate = System.Now();
            objTask.OwnerId = Userinfo.getUserId();
            objTask.Status = 'Completed';
            objTask.Subject = 'Called and left message with person or voicemail';
            objTask.WhatId = (Id)AccountID;
            objTask.RecordTypeId = TaskRecordTypeId;
            
            insert objTask;         
            pr = new Pagereference('/' + AccountID);            
        }
        catch(Exception ex){        
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,ex.getMessage()));   
        }        
        return pr;
    }
    
}

 

Thanks so much,
Sean

  • September 08, 2010
  • Like
  • 0

I am trying to see if there is a way I can add a button to a related lists section in order to View All even if there are less than 5 related records so users can print out the information. 

 

Is there a way to use the view all button that is already available when there are more than 5 records?  I was thinking there may be a way to call it from a visualforce page but I'm not sure how I might go about doing that.

 

Thanks for any suggestions

  • September 07, 2010
  • Like
  • 1

I'm trying to create a trigger to send an email notification to the original creator of a case anytime a Case Comment is added.  I've tried everything and I can not get the syntax correct.  Can anyone offer any suggestions.  I keep getting an error with the query statement stating unexpected token 'cc'

 

The code I have is:

 

trigger NotifyCaseCreator on CaseComment (after delete, after insert, after undelete,after update) {

 
for(CaseComment cc:[select parent.createdby.email from cc where id = cc record id]){
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {cc};
     }  
           mail.setToAddresses(toAddresses);
           mail.setSubject('A New Case Comment Has Been Added');
           string msg = 'A Comment has been added to a Case that you had created.  The Comment was added by UserID:';
      
           for (CaseComment u : Trigger.new) {
          msg = msg + u.CreatedBy;
         }

mail.setHtmlBody(msg);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


}

Hi All,

 

I need to send an email notification to the creator of a Case anytime a new Case Comment is added.  So far I have only been able to send an email to a static email address.  Is there a way to insert the email address of the User that created the Parent Case?  So far I have:

 

trigger NotifyCaseCreator on CaseComment (after delete, after insert, after undelete,
after update) {

    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {'me@mydomain.com'};
    
        mail.setToAddresses(toAddresses);
        mail.setSubject('A New Case Comment Has Been Added');
        string msg = 'A Comment has been added to a Case that you had created.  The Comment was added by:';

    for (CaseComment u : Trigger.new) {
    msg = msg + u.CreatedById;
}

mail.setHtmlBody(msg);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


    }

I am trying to see if there is a way I can add a button to a related lists section in order to View All even if there are less than 5 related records so users can print out the information. 

 

Is there a way to use the view all button that is already available when there are more than 5 records?  I was thinking there may be a way to call it from a visualforce page but I'm not sure how I might go about doing that.

 

Thanks for any suggestions

  • September 07, 2010
  • Like
  • 1

I'm trying to create a trigger that will update a custom object that we have called a participant record anytime a user submits a cancellation case.  The problem I'm running into is that we also use a custom object called programs and we've made a change so that multiple records use the same name.  I am trying to use an if else statement and the division to differentiate the different program names.

 

Right now the trigger is not getting to the end to update the participant record but I'm not sure why.  If anyone has any suggestions it would be a huge help.

 

trigger CancellationCaseTrigger on Case (before insert, before update) {
    for (Case thiscase: System.Trigger.new) {
    
       
        // DE-6 : Modifed Orignal Trigger to Only Cancel the Program specified on the Case Object
        Participant__c[] Participants = [Select Id from Participant__c WHERE Account_del__c = :thiscase.AccountId AND Program__C = :progORsvc.id  ];
        
        for (Participant__c p : Participants) {
            p.Cancellation_Case__c = thiscase.Id;
            p.Program_Status__c = 'Cancelled';
            p.Cancel_Date__c =  thiscase.Program_End_Date__c;
            p.Enrolled__c = 'No';
            
            update p;
        }
    }
    }
}}}}}}

 

I'm trying to write a workflow rule formula that will allow me to check if a custom field has been changed and if one of a list of users is the account coordinator.  It seems like it should work but it's not triggering the workflow rule.  What I have now is:

 

AND( 
OR( 
Account_Coordinator__c = "meghan Buster", 
Account_Coordinator__c = "Sarah Isley", 
Account_Coordinator__c = "Tammy Rackard", 
Account_Coordinator__c = "Sean Carr", 
Account_Coordinator__c = "Teresa Wells" ), 
ISCHANGED( Drop_Date_Change_Description__c))

 

If anyone could provide some advice it would be much appreciated.

 

Thanks,


Sean

I am trying to write a validation rule that will prevent users from going back to 'Sent' as a campaign member status.  I have rule but it is preventing the status from changing From 'Sent' and I need it to prevent users from going back to 'Sent'.  Can anyone please help.  The code is below

 

AND(ISCHANGED(Status),
NOT(ISPICKVAL(Status,"Sent")))

 

Thanks,


Sean

I have created a VisualForce page that I would like to use on a custom object I've built.  I am trying to set it so that whenever someone enters a new record or whenever a record is edited, the new VisualForce page with graphics will display.  On the page I have it set to use the Custom Accountability controller with:

 

 

<apex:page standardController="Accountability__c"   RecordSetVar="Accountability">
<apex:variable value="{!Accountability__c}" var="acc"/> 
    <apex:form >

 

<apex:page standardController="Accountability__c" RecordSetVar="Accountability">

<apex:variable value="{!Accountability__c}" var="acc"/>     

<apex:form >

 

Can anyone please tell me what I am doing wrong and I how I can over ride the standard view with my custom one.

 

Thanks so much,

 

Sean

Hi All,

 

I need to send an email notification to the creator of a Case anytime a new Case Comment is added.  So far I have only been able to send an email to a static email address.  Is there a way to insert the email address of the User that created the Parent Case?  So far I have:

 

trigger NotifyCaseCreator on CaseComment (after delete, after insert, after undelete,
after update) {

    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    String[] toAddresses = new String[] {'me@mydomain.com'};
    
        mail.setToAddresses(toAddresses);
        mail.setSubject('A New Case Comment Has Been Added');
        string msg = 'A Comment has been added to a Case that you had created.  The Comment was added by:';

    for (CaseComment u : Trigger.new) {
    msg = msg + u.CreatedById;
}

mail.setHtmlBody(msg);

Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


    }