• Gdickens3
  • NEWBIE
  • 20 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 6
    Replies
We are using a 3rd party tool (DBAmp) to execute a QueryAll api call against the Task table and are receiving the QUERY_TIMEOUT error.  Salesforce directed me here when I asked for the query timeout to be increased to 10 minutes ..

My company has been using SFDC since 2005 - there are a lot of report/dashboard folders.  The new sharing does not automatically allow owners of the folders to add users to the auto refresh unless they have been added.  How can I add "all users" as individual users?  I can and have created groups but it would be nice to let the owner of the folders add whoever they want without me creating groups as needed.

I have a custom object with a trigger that was created before my time - I am just learning triggers.  I have pasted my code below.  My Users are getting the error when saving "Error:Apex trigger chassis_notification caused an unexpected exception, contact your administrator: chassis_notification: execution of BeforeUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing target address (target, to, cc, bcc): []: Trigger.chassis_notification: line 149, column 1"

 

 

trigger chassis_notification on Warranty__c (before update) 
{
  for(Warranty__c w : Trigger.new) 
  {
     // If this is a Chassis, send email to notify accounting
     if(w.Chassis_Unit__c == True && 
        w.Warranty_Status__c == 'Approved' && 
        w.ChassisNotificationSent__c != True &&
        w.Replace_with_vRecovery__c == False
        )
     {
        Account company = [select Id, Name from Account where Id = :w.Account_Name__c];
        Contact contact = [select Id, Name from Contact where Id = :w.Contact_Name__c];
        User caseOwner = [select Id, Email from User where Id = :w.OwnerId];
        Asset asset = [select Id, name from Asset where Id = :w.Asset_Tag__c];
        Case myCase = [select Id, CaseNumber from Case where Id = :w.Associated_Case__c];
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses;
        mail.setReplyTo('support@unitrends.com');
        mail.setSenderDisplayName('Unitrends Support');
        if(w.Is_GE__c == True)
        {
            toAddresses = new String[] {'dcrosby@unitrends.com', 
                                        'briant@unitrends.com',
                                        'luke@unitrends.com',
                                        'twallick@unitrends.com', 
                                        'dsapp@unitrends.com',
                                        'geisenhower@unitrends.com', 
                                         caseOwner.Email, 
                                        'dmccraw@unitrends.com',
                                        'jrast@unitrends.com',
                                        'accounting@unitrends.com'
                                        };
            mail.setSubject('GE Customer: A New Warranty Request has been Approved & Includes a Chassis or Unit Replacement');
            mail.setPlainTextBody
                        ('This customer warranty to be fulfilled by RAVE.' + '\n\n\n' +
                         'The following Warranty Request has been approved and may require' + '\n' +
                         'your attention as it includes a chassis or unit replacement:'+ '\n\n' +
                         'Company:\t\t\t' + company.Name + '\n' +
                         'Contact\t\t\t' + contact.Name + '\n' +                         
                         'Asset Tag:\t\t\t' + asset.Name + '\n' +
                         'Associated Case:\t\t' + myCase.CaseNumber + '\n' +
                         'Warranty Shipment Number:\t' + w.Name + '\n\n' +
                         'Click on the link to access the Warranty:\n' + 'https://na2.salesforce.com/' + w.Id
                        );
        }
        else if(w.Platinum_Support__c == True)
        {
            if(w.Manufacturer__c == 'Rave') {
                toAddresses = new String[] {'dcrosby@unitrends.com', 
                                            'briant@unitrends.com',
                                            'luke@unitrends.com',
                                            'unitrendsccd@chipcocomputer.com', 
                                            'twallick@unitrends.com', 
                                            'dsapp@unitrends.com',
                                            'geisenhower@unitrends.com', 
                                             caseOwner.Email, 
                                            'dmccraw@unitrends.com',
                                            'jrast@unitrends.com',
                                            'accounting@unitrends.com'
                                            };
            }
            else if(w.Manufacturer__c == 'CHIPCO') {
                toAddresses = new String[] {'dcrosby@unitrends.com', 
                                            'briant@unitrends.com',
                                            'luke@unitrends.com',
                                            'unitrendsccd@chipcocomputer.com', 
                                            'twallick@unitrends.com', 
                                            'dsapp@unitrends.com',
                                            'geisenhower@unitrends.com', 
                                             caseOwner.Email, 
                                            'dmccraw@unitrends.com',
                                            'jrast@unitrends.com',
                                            'accounting@unitrends.com'
                                            };
            }
            else if(w.Manufacturer__c == 'MBX') {
                toAddresses = new String[] {'dcrosby@unitrends.com', 
                                            'briant@unitrends.com',
                                            'luke@unitrends.com',
                                            'support@mbx.com', 
                                            'twallick@unitrends.com', 
                                            'dsapp@unitrends.com',
                                            'geisenhower@unitrends.com', 
                                             caseOwner.Email, 
                                            'dmccraw@unitrends.com',
                                            'jrast@unitrends.com',
                                            'accounting@unitrends.com'
                                            };
        
            }
            mail.setSubject('Platinum Customer: A New Warranty Request has been Approved & Includes a Chassis or Unit Replacement');
            mail.setPlainTextBody
                        ('This customer has platinum support and requires next day shipping!!!' + '\n\n\n' +
                         'The following Warranty Request has been approved and may require' + '\n' +
                         'your attention as it includes a chassis or unit replacement:'+ '\n\n' +
                         'Company:\t\t\t' + company.Name + '\n' +
                         'Contact\t\t\t' + contact.Name + '\n' +                         
                         'Asset Tag:\t\t\t' + asset.Name + '\n' +
                         'Associated Case:\t\t' + myCase.CaseNumber + '\n' +
                         'Warranty Shipment Number:\t' + w.Name + '\n\n' +
                         'Click on the link to access the Warranty:\n' + 'https://na2.salesforce.com/' + w.Id
                        );
        }
        else
        {
            if(w.Manufacturer__c == 'CHIPCO') {
                toAddresses = new String[] {'dcrosby@unitrends.com', 
                                            'briant@unitrends.com',
                                            'luke@unitrends.com',
                                            'unitrendsccd@chipcocomputer.com', 
                                            'twallick@unitrends.com', 
                                            'dsapp@unitrends.com',
                                            'geisenhower@unitrends.com', 
                                             caseOwner.Email, 
                                            'dmccraw@unitrends.com',
                                            'jrast@unitrends.com',
                                            'accounting@unitrends.com'
                                            };
            }
            else if(w.Manufacturer__c == 'MBX') {
                toAddresses = new String[] {'dcrosby@unitrends.com', 
                                            'briant@unitrends.com',
                                            'luke@unitrends.com',
                                            'support@mbx.com', 
                                            'twallick@unitrends.com', 
                                            'dsapp@unitrends.com',
                                            'geisenhower@unitrends.com', 
                                             caseOwner.Email, 
                                            'dmccraw@unitrends.com',
                                            'jrast@unitrends.com',
                                            'accounting@unitrends.com'
                                            };
        
            }
            mail.setSubject('A New Warranty Request has been Approved & Includes a Chassis or Unit Replacement');
            mail.setPlainTextBody
                        ('The following Warranty Request has been approved and may require' + '\n' +
                         'your attention as it includes a chassis or unit replacement:'+ '\n\n' +
                         'Company:\t\t\t' + company.Name + '\n' +
                         'Contact\t\t\t' + contact.Name + '\n' +                         
                         'Asset Tag:\t\t\t' + asset.Name + '\n' +
                         'Associated Case:\t\t' + myCase.CaseNumber + '\n' +
                         'Warranty Shipment Number:\t' + w.Name + '\n\n' +
                         'Click on the link to access the Warranty:\n' + 'https://na2.salesforce.com/' + w.Id
                        );
        }
        mail.setToAddresses(toAddresses);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        w.ChassisNotificationSent__c = True;
     }
  }
}

 

 

 

I have modified a code for inserting the account owner on an opportunity record to show the same on a case object, but getting error: Compile Error: Incompatible element type Schema.SObjectField for collection of Id at line 4 column 36

 

I am new to apex and have only successfully modified current triggers when fields change, any help is appreciated.

 

trigger trgAccOwner on Case (before insert,before update) {
    Set<Id> acctIDs = new Set<Id>();
    for(Case tl:Trigger.new) {
        if(case.AccountId != null) acctIDs.add(case.AccountId);
    }
    
    Map<Id, Account> acctMap = new Map<Id, Account>([select Owner.Name from Account where Id in :acctIDs]);

for(Case tl: Trigger.new) {
        if(case.AccountId != null) case.Account_Owner__c = acctMap.get(Case.AccountId).Owner.Name;
    }
}

 

 

Hi,

 

I have a custom object "xyz" with a look up field to accounts

 

We need to see the name of the account owner, I cannot get it via formula (well, I could, but then I would need to modify the formula each time a new user is created and TEXT( Account__r.Ownership ) didn´t work)

 

I guess this is a simple trigger, to get the account owner name populated in the "xyz" object...

 

 

Any sample trigger you may have please to direct me to the right direction....

 

Thank you!!:)