• Matt Beshany
  • NEWBIE
  • 30 Points
  • Member since 2014
  • Sales Analyst
  • Great-West Financial

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 1
    Questions
  • 3
    Replies
I'm trying to write a trigger to make sure certain fields are not empty based on the status that is chosen.  I have several different types of fields I'm trying to validate.  My code is below but it doesn't seem to be validating anything

Resolution_Detail__c = RTF
Workaround_ICA__c = RTF
Defect_Type_Multi__c = multipicklist
Declined_Reason__c= picklist
NPI_Numbertext__c = plain text
NPI_Tracking_Link__c = URL
CPI_Numbertext__c = plain text
CPI_Tracking_Link__c = URL
Change_Numbertext__c = plain text
CPI_Tracking_Link__c = URL





 
trigger CWStatusValidation on Case (before update, before insert)
{

              
        for (Case objCase : Trigger.new)
        {
           //If Status is any of the following and Resolution Detail is empty, prompt to fill in.
           if((objCase.Status == 'Closed - Cancelled' || objCase.Status == 'Closed - Unable to Reproduce' || objCase.Status == 'Closed - Duplicate'
           || objCase.Status == 'Recurring Incident') && objCase.Resolution_Detail__c == '')            
           {
                trigger.new[0].addError('Please fill in the Resolution Detail for this case.');
           }
              //If Status is any of the following and ICA is empty, prompt to fill in.
              if((objCase.Status == 'Pending - RCA' || objCase.Status == 'Pending - Customer Validation' 
              || objCase.Status == 'Pending - Dealer Validation' || objCase.Status == 'Pending - Evaluation') && objCase.Workaround_ICA__c == '')             
              {
                trigger.new[0].addError('Please fill in the Workaround / ICA for this case.');
              }
                    //If Status = Pending - CPI, fill in Resolution Details, CPI Number and CPI Tracking Link
                    if(objCase.Status == 'Pending - CPI' && objCase.CPI_Numbertext__c == ' ' && objCase.CPI_Tracking_Link__c == ' ' && objCase.Resolution_Detail__c == '' )            
                    {
                        trigger.new[0].addError('Please fill in the Resolution Details, CPI Number and CPI Tracking Link for this case.');
                    }
                         //If the Status = Closed - Declined, fill in Resolution Detail, Defect Type and Declined Reason.
                         if(objCase.Status == 'Closed - Declined' && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' && objCase.Declined_Reason__c == '')
                         {
                           trigger.new[0].addError('Please fill in the Resolution Details, Defect Type and Declined Reason for this case.');
                         }
                            //If the Status = Pending - NPI, fill in Resolution Detail, NPI Number and NPI Tracking Link.
                            if(objCase.Status == 'Pending - NPI' && objCase.Resolution_Detail__c == '' && objCase.NPI_Numbertext__c == null && objCase.NPI_Tracking_Link__c == null)
                            {
                               trigger.new[0].addError('Please fill in the Resolution Details, NPI Number and NPI Tracking Link for this case.');
                            }
                                //If the Status = Pending - Change, fill in Resolution Detail, Change Number and Change Tracking Link.
                                if(objCase.Status == 'Pending - Change' && objCase.Resolution_Detail__c == '' && objCase.Change_Number__c == '' && objCase.Change_Tracking_Link__c == '')
                                {
                                   trigger.new[0].addError('Please fill in the Resolution Details, Change Number and Change Tracking Link for this case.');
                                }
                                    //If the Status is any of the following, fill in Resolution Detail and Defect Type.
                                    if((objCase.Status == 'Closed - Resolved' || objCase.Status == 'Closed - No Response') && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' )
                                    {
                                       trigger.new[0].addError('Please fill in the Resolution Details and Defect Type for this case.');
                                    }
           
         }       
}
  • November 24, 2014
  • Like
  • 1
Does anybody know how to set up access to a reps calendar so that community users (client employees) can see certain, public, events and register for them, all within their community portal? On top of that, I would like to be able to set a limit on the number of people who can attend an event (similar to how Dreamforce events operate). Any input is greatly appreciated.

Thanks!
Does anybody know how to set up access to a reps calendar so that community users (client employees) can see certain, public, events and register for them, all within their community portal? On top of that, I would like to be able to set a limit on the number of people who can attend an event (similar to how Dreamforce events operate). Any input is greatly appreciated.

Thanks!
I'm trying to write a trigger to make sure certain fields are not empty based on the status that is chosen.  I have several different types of fields I'm trying to validate.  My code is below but it doesn't seem to be validating anything

Resolution_Detail__c = RTF
Workaround_ICA__c = RTF
Defect_Type_Multi__c = multipicklist
Declined_Reason__c= picklist
NPI_Numbertext__c = plain text
NPI_Tracking_Link__c = URL
CPI_Numbertext__c = plain text
CPI_Tracking_Link__c = URL
Change_Numbertext__c = plain text
CPI_Tracking_Link__c = URL





 
trigger CWStatusValidation on Case (before update, before insert)
{

              
        for (Case objCase : Trigger.new)
        {
           //If Status is any of the following and Resolution Detail is empty, prompt to fill in.
           if((objCase.Status == 'Closed - Cancelled' || objCase.Status == 'Closed - Unable to Reproduce' || objCase.Status == 'Closed - Duplicate'
           || objCase.Status == 'Recurring Incident') && objCase.Resolution_Detail__c == '')            
           {
                trigger.new[0].addError('Please fill in the Resolution Detail for this case.');
           }
              //If Status is any of the following and ICA is empty, prompt to fill in.
              if((objCase.Status == 'Pending - RCA' || objCase.Status == 'Pending - Customer Validation' 
              || objCase.Status == 'Pending - Dealer Validation' || objCase.Status == 'Pending - Evaluation') && objCase.Workaround_ICA__c == '')             
              {
                trigger.new[0].addError('Please fill in the Workaround / ICA for this case.');
              }
                    //If Status = Pending - CPI, fill in Resolution Details, CPI Number and CPI Tracking Link
                    if(objCase.Status == 'Pending - CPI' && objCase.CPI_Numbertext__c == ' ' && objCase.CPI_Tracking_Link__c == ' ' && objCase.Resolution_Detail__c == '' )            
                    {
                        trigger.new[0].addError('Please fill in the Resolution Details, CPI Number and CPI Tracking Link for this case.');
                    }
                         //If the Status = Closed - Declined, fill in Resolution Detail, Defect Type and Declined Reason.
                         if(objCase.Status == 'Closed - Declined' && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' && objCase.Declined_Reason__c == '')
                         {
                           trigger.new[0].addError('Please fill in the Resolution Details, Defect Type and Declined Reason for this case.');
                         }
                            //If the Status = Pending - NPI, fill in Resolution Detail, NPI Number and NPI Tracking Link.
                            if(objCase.Status == 'Pending - NPI' && objCase.Resolution_Detail__c == '' && objCase.NPI_Numbertext__c == null && objCase.NPI_Tracking_Link__c == null)
                            {
                               trigger.new[0].addError('Please fill in the Resolution Details, NPI Number and NPI Tracking Link for this case.');
                            }
                                //If the Status = Pending - Change, fill in Resolution Detail, Change Number and Change Tracking Link.
                                if(objCase.Status == 'Pending - Change' && objCase.Resolution_Detail__c == '' && objCase.Change_Number__c == '' && objCase.Change_Tracking_Link__c == '')
                                {
                                   trigger.new[0].addError('Please fill in the Resolution Details, Change Number and Change Tracking Link for this case.');
                                }
                                    //If the Status is any of the following, fill in Resolution Detail and Defect Type.
                                    if((objCase.Status == 'Closed - Resolved' || objCase.Status == 'Closed - No Response') && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' )
                                    {
                                       trigger.new[0].addError('Please fill in the Resolution Details and Defect Type for this case.');
                                    }
           
         }       
}
  • November 24, 2014
  • Like
  • 1
I am not sure how to accomplish this, however, our CS\TS would like to create an opportunity directly from the case. I can find a million ways to do it the other way around, but not sure how to do this from a case.  Can you do a url hack? Or JS button?  I would rather not use APEX but can if that is the only option.

Thank you very much.
I'm trying to write a trigger to make sure certain fields are not empty based on the status that is chosen.  I have several different types of fields I'm trying to validate.  My code is below but it doesn't seem to be validating anything

Resolution_Detail__c = RTF
Workaround_ICA__c = RTF
Defect_Type_Multi__c = multipicklist
Declined_Reason__c= picklist
NPI_Numbertext__c = plain text
NPI_Tracking_Link__c = URL
CPI_Numbertext__c = plain text
CPI_Tracking_Link__c = URL
Change_Numbertext__c = plain text
CPI_Tracking_Link__c = URL





 
trigger CWStatusValidation on Case (before update, before insert)
{

              
        for (Case objCase : Trigger.new)
        {
           //If Status is any of the following and Resolution Detail is empty, prompt to fill in.
           if((objCase.Status == 'Closed - Cancelled' || objCase.Status == 'Closed - Unable to Reproduce' || objCase.Status == 'Closed - Duplicate'
           || objCase.Status == 'Recurring Incident') && objCase.Resolution_Detail__c == '')            
           {
                trigger.new[0].addError('Please fill in the Resolution Detail for this case.');
           }
              //If Status is any of the following and ICA is empty, prompt to fill in.
              if((objCase.Status == 'Pending - RCA' || objCase.Status == 'Pending - Customer Validation' 
              || objCase.Status == 'Pending - Dealer Validation' || objCase.Status == 'Pending - Evaluation') && objCase.Workaround_ICA__c == '')             
              {
                trigger.new[0].addError('Please fill in the Workaround / ICA for this case.');
              }
                    //If Status = Pending - CPI, fill in Resolution Details, CPI Number and CPI Tracking Link
                    if(objCase.Status == 'Pending - CPI' && objCase.CPI_Numbertext__c == ' ' && objCase.CPI_Tracking_Link__c == ' ' && objCase.Resolution_Detail__c == '' )            
                    {
                        trigger.new[0].addError('Please fill in the Resolution Details, CPI Number and CPI Tracking Link for this case.');
                    }
                         //If the Status = Closed - Declined, fill in Resolution Detail, Defect Type and Declined Reason.
                         if(objCase.Status == 'Closed - Declined' && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' && objCase.Declined_Reason__c == '')
                         {
                           trigger.new[0].addError('Please fill in the Resolution Details, Defect Type and Declined Reason for this case.');
                         }
                            //If the Status = Pending - NPI, fill in Resolution Detail, NPI Number and NPI Tracking Link.
                            if(objCase.Status == 'Pending - NPI' && objCase.Resolution_Detail__c == '' && objCase.NPI_Numbertext__c == null && objCase.NPI_Tracking_Link__c == null)
                            {
                               trigger.new[0].addError('Please fill in the Resolution Details, NPI Number and NPI Tracking Link for this case.');
                            }
                                //If the Status = Pending - Change, fill in Resolution Detail, Change Number and Change Tracking Link.
                                if(objCase.Status == 'Pending - Change' && objCase.Resolution_Detail__c == '' && objCase.Change_Number__c == '' && objCase.Change_Tracking_Link__c == '')
                                {
                                   trigger.new[0].addError('Please fill in the Resolution Details, Change Number and Change Tracking Link for this case.');
                                }
                                    //If the Status is any of the following, fill in Resolution Detail and Defect Type.
                                    if((objCase.Status == 'Closed - Resolved' || objCase.Status == 'Closed - No Response') && objCase.Resolution_Detail__c == '' && objCase.Defect_Type_Multi__c == '' )
                                    {
                                       trigger.new[0].addError('Please fill in the Resolution Details and Defect Type for this case.');
                                    }
           
         }       
}
  • November 24, 2014
  • Like
  • 1
Hi, I am new to apex trigger programming, though a long-time programmer.

I would like to track the date and time of day when tasks are marked "Completed". This functionality is not captured by Due Date or Date of Last Activity.

trigger DateCompleted on Task ( before insert, before update )
{
try
{
// task.DateCompleted = todaysDate();
// task.TimeCompleted = now;
}
catch ( Exception ex )
{
}
}

I'd appreciate your help on this - also (and related), I looked around for some time, but could not find a resource with a bunch of example Apex triggers - this would be really helpful.
  • January 13, 2009
  • Like
  • 1