• Gdickens3
  • NEWBIE
  • 20 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 6
    Replies
I am using an app exchange roudn robin case assignment which is working great.  However, because the case is assigned to the queue and then to the inividual owner in the same edit action the workflow to alert the case owner is not firing.  I have tried using the last modified date or date opened as a trigger point but it is not working.  I believe I will need to have a simle trigger fire after the round robin has finsihed and the individual owner has been assigned.  I have litte experience writing these and have only modified current triggers.  I can't use the standard case assignment notification because the first owner is the queue.

The case history looks like this: (assigned to queue and reassigned to queue member in single action)
2/23/2015 9:06 AM G.Dickens  Changed Case Owner from L1 Case Queue to Luke S.
      Changed Owner (Assignment) from G.Dickens to L1 Case Queue.
My code below is the one I'd like to modify - it works fine for looking at fields on the account, but I am trying to use something similar but looking at the user clicking the button.  I gett an error using userid or username.

Current Code (working):
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")};
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")};
if('{!Account.RecordType}' == "Unitrends - End User" || '{!Account.Account_Status__c}'=="Prospect")
alert ("Cases should be created from the Asset for current customers or from an Opportunity for Prospects");
else
open('500/e?retURL=%2F500%2Fo&RecordType=012300000000Xth&ent=Case');

NEW CODE for USER:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}; 
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}; 
if('{!User.Id}'= "00540000001sVhY" )
alert ("Cases should be created from the Asset for current customers or from an Opportunity for Prospects"); 
else 
open('500/e?retURL=%2F500%2Fo&RecordType=012f0000000D63a&ent=Case');
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;
    }
}

 

 

First time poster/coder

 

I have tried to create a workflow to update a task subject when my user sends an email using the BCC to Salesforce.  However I think it might need to be updated 'before' rather than how a workflow operates on user action.  It seems simple enough, but I've never created a code.  Is there any help out there?


Thanks!

We have a formula to track "last activity age" (formula is: TODAY() - LastActivityDate)  However since we have Eloqua making daily automatic activity this field is not a true representation of our employee activity. I can filter this somewhat in reports by omitting the Eloqua id - but management this field to dynamically look at a view to determine account rep's activity. 

 

Is there a way to limit this field to update only if the activity is not done by the Eloqua userid (0054000000195mL)

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 ..
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!!:) 

 

  • November 04, 2011
  • Like
  • 0