• Marcoppp
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi,

I have a question, namely could somebody tell me the best way to send alert on Opportunity change to all Opportunity Contacts? Can this be done by trigger as below? although I could not get this working as I am getting an error on email, could somebody help me with this??

List<Opportunity> oList = Trigger.old;
List<Opportunity> nList = trigger.new;

  if(oList[0].StageName !=nList[0].StageName) {

      Set<Id> OpportunityIds= new Set<Id>();
      Map<id,Contact> ConMap = new Map<id,Contact>([select id,LastName,FirstName,email from Contact where Id in :OpportunityIds]);

      List<Contact>  sList = [select id,LastName,FirstName,email from Contact where Account.Id =:nList[0].accountid limit 1];

      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

        mail.setSenderDisplayName('Salesforce Support');
        mail.setUseSignature(false);
        mail.setBccSender(false);
        mail.setSaveAsActivity(false);


      EmailTemplate et=[Select id from EmailTemplate limit 1];
      mail.setTemplateId(et.id);

      mail.setToAddresses(new String[] {sList[0].email});
      mail.setTargetObjectId(sList[0].id);
      mail.setSaveAsActivity(false);

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

Thanks

Hi 

 

Could somebody tell me how to make this if else statment working correctly?? Namely I would like to have 3 more statments like the one below as based on validation I want to display different messages  for if and for else. How to place 2 more if else statment ??? 

if (aText == 'A' ) {
    this.success = response__c;
    this.validationMessage = null;

        } else { 
                   this.validationMessage= validationMessages.NoValid__c;
                   this.success = null;

 

}

 

Thanks in advance

Hi

 

I am a new to apex so could somebody help me with this???

 

In my custom settings I have Object called MyPersonalSettings__c in my code I have something like:

 

settings = MyPersonalSettings__c.getValues('mypersonalsettings')

 

But it is possible to replace 'mypersonalsettings' with somethng like a method: for example getValues(method) where method could have something like that

if (condition == true)

  set mypersonalsettings

else if (condition  == false)

  set yoursettings

else ..

 

Could somebody provide my with some example, I will be very appreciate for that 

 

Thank

 

 

Hi

 

I am a new to apex so could somebody help me with this???

 

In my custom settings I have Object called MyPersonalSettings__c in my code I have something like:

 

settings = MyPersonalSettings__c.getValues('mypersonalsettings')

 

But it is possible to replace 'mypersonalsettings' with somethng like a method: for example getValues(method) where method could have something like that

if (condition == true)

  set mypersonalsettings

else if (condition  == false)

  set yoursettings

else ..

 

Could somebody provide my with some example, I will be very appreciate for that 

 

Thank