• DUGLO
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
CONTAINS("AL:AR:CA:FL:GA:IL:IN:KY:LA:MD:MI:MN:MO:MS:NC:NJ:NY:OH:OK:PA:SC:TN:TX:VA:WI", BillingState)

I only want this formula field to return true if the billing state is set to one of these values. After creating it though I noticed the formula field was returning true when billing state is blank. Does anyone know why this could be happening?
  • January 18, 2018
  • Like
  • 0
Hi,

This is the first Apex trigger I've deployed into production. It creates a renewal opportunity when an original opportunity gets set to closed won. I'm looking for your feedback as to whether it is properly bulkified. When using the data loader I've run into some errors that suggests it's not. Here's a copy of the trigger: 
 
trigger CreateRenewalOppty on Opportunity (before update) {
    
    List<Opportunity> renewals = new List<Opportunity>();
    
    for (Opportunity opp : trigger.new) {
     Opportunity oldOpp = Trigger.oldMap.get(opp.Id);
        Boolean oldOppIsWon = oldOpp.StageName.equals('Closed Won');
        Boolean newOppIsWon = opp.StageName.equals('Closed Won');
        Date myDate = System.today();
        String acctName = [SELECT Account.Name
                          FROM Opportunity
                          WHERE ID IN: trigger.new
                          Limit 1].Account.Name;
        
        
                
        
        if (!oldOppIsWon &&
           newOppisWon &&
           helperClass.firstRun &&
           (opp.Business__c == 'Site' ||
            opp.Business__c == 'District')) {
                Opportunity renewal = new Opportunity();
                renewal.Name = acctName + ' ' + myDate.year() + '-1';
                renewal.CloseDate = opp.CloseDate + 365;
                renewal.StageName = 'Qualified Renewal';
                renewal.AccountId = opp.AccountId;
                renewal.Type = 'Renewal Business';
                renewal.Business__c = opp.Business__c;
               renewal.Term_Expiration_Date__c = opp.Term_Expiration_Date__c;
                renewal.Term_Start_Date__c = opp.Term_Start_Date__c;
                renewal.Primary_Contact_del__c = opp.Primary_Contact_del__c;
                renewal.Subscription_ID__c = opp.Subscription_ID__c;
                renewal.Amount = opp.Amount;
                renewal.Trigger_AM_Sequence__c = true;
                renewal.Notes__c = opp.Notes__c;
                renewal.Student_Username__c = opp.Student_Username__c;
                renewal.Area_of_Interest__c = opp.Area_of_Interest__c;
                renewal.Other_Area_of_Interest__c = opp.Other_Area_of_Interest__c;
                renewal.Postmortem_Notes__c = opp.Postmortem_Notes__c;
                renewal.Activation_Link__c = opp.Activation_Link__c;
                helperClass.firstRun = false;
                              
                
            renewals.add(renewal);
                
              
            }
         
    }
       System.debug('firstRun is ' + helperClass.firstRun);
            System.debug('The list contains ' + renewals.size() + ' opptys');
         try {
           insert renewals; 
         } catch (Exception e) {
           System.debug('Exception type caught ' + e.getTypeName());
         }


I followed the advice to add renewal opportunities to a list and then insert the list - so thought this meant the trigger was properly bulkified? Any other tips on how to improve this trigger would be greatly appreciated as well. Thanks!
  • July 07, 2016
  • Like
  • 0
So the structure I have is this:

Record of Custom Object Type A has a related list of multiple records of Custom Object Type B.


And this is what I'm looking to do:

Object Type B has a Currency field, and Object Type A has a field that is inteded to be the Sum of that Currency field for all records in the related list. Whenever any record of Object Type B is updated, I need the Sum field on Object Type A to calculate the new sum. (Essentially it is a rollup sum, but I cannot use a rollup field because these do not have a Master-Detail relationship.)


Example:

Initial State:
  • Object Type A Record SumField = 100
    • Related ObjectB Record 1 CurrencyField = 50
    • Related ObjectB Record 2 CurrencyField = 30
    • Related ObjectB Record 3 CurrencyField = 20
User Action:
  • Related ObjectB Record 2 CurrencyField is changed from 30 to 80
Desired End State:
  • Object Type A Record SumField = 150
    • Related ObjectB Record 1 CurrencyField = 50
    • Related ObjectB Record 2 CurrencyField = 80
    • Related ObjectB Record 3 CurrencyField = 20
Hi,
I am not able to understand the below question correctly Please help me out. - 
Create a class that has a method accepting two strings. The method searches for contacts that have a last name matching the first string and a mailing postal code (API name: MailingPostalCode) matching the second. It gets the ID and Name of those contacts and returns them.The Apex class must be called 'ContactSearch' and be in the public scope.
The Apex class must have a public static method called 'searchForContacts'.
The 'searchForContacts' method must accept two incoming strings as parameters, find any contact that has a last name matching the first, and mailing postal code matching the second string. The method should return a list of Contact records with at least the ID and Name fields.
The return type for 'searchForContacts' must be 'List<Contact>'.