• CKN
  • NEWBIE
  • 0 Points
  • Member since 2010

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 16
    Replies

I need to implement the following; Based on the below criteria for case creatorID and case owner id, I want to display a message ( not a error message) stating " This case was created by a CAS agent. It will get reassigned to the case creator"). Right now my code displays an error message but the user has to go back to the case and change owner. 

 

Is there a way to display a message and change the ownerid automatically via the trigger?

 

if ((a.STATUS == 'Awaiting Internal Response'&& a.RecordTypeID == '012300000004rDZ')&&  
                     (casecreatoriwdalias =='CAS' ||casecreatoriwdalias =='TASR/P1')&&  
                       (iWdAliasCaseOwner == 'DISP'|| iWdAliasCaseOwner == 'RCC'))     {
                         a.IWD_Testing__c = 'trigger 2 enter the loop';    
                         a.iwd_check__c    = true;                        
                                }// status
                                
            if (a.iwd_check__c){
                   err_msg = 'Case opened by TASR/P1 or CAS Agent: Please assign it to:';
                   err_msg += casecreatoriwdalias + ' ' + a.CreatedById + '<br>';
                   a.addError(err_msg);

                   a.ownerid  = caseowner;
                             } 

 

 

Thanks

Chitra

  • September 22, 2010
  • Like
  • 0

Hi,

Just wondering if there are any system generated trace files in SFDC which might help with debugging or troubleshooting any code related issues.

 

  • July 09, 2010
  • Like
  • 0

Hi,

 

We are getting the following error when trying to deploy a trigger.

 

 

ACCFTriggerValidation.myTest()Class773Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, tgrBatchJobs: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com ...

 

The code snippet is attached. We are not sure why the batch upload fails and how we should index our fields. We are new to APEX so not sure how to get started.

 

// code snippet

//BATCH VALIDATION
      PreferredContact__c mycontact = new PreferredContact__c(Account__c=accounttest.id, preferredemail__C='user@site.com', preferredfax__c='3345567890');
      insert mycontact;
        
    PreferredIA__c testme = new PreferredIA__c(OKSendSurvey__c = true, account__c = accounttest.id, specialist__c = userid[0].id);
    insert testme;
    
    Batch_Job__c[] jobme = new batch_job__c[]{new Batch_Job__c(IsRunning__c = true, Description__c = 'test neutral', JobType__c = 'Test Email', DeleteMe__c = false),
                                           new Batch_Job__c(isRunning__c = true, Description__c = 'test positive', jobType__c = 'Send Surveys', DeleteMe__c = false),
                                            new Batch_Job__c(isRunning__c = true, Description__c = 'test positive', jobType__c = 'Send Surveys', DeleteMe__c = false)};
    insert jobme;
    
    jobme[0].Deleteme__c = true;

// error on line 77 column 3

    update jobme[0];
    
    jobme[1].Deleteme__c = true;
    update jobme[1];

  • July 09, 2010
  • Like
  • 0

I am running into the governor limit issue since I have the SQls inside the for loop. I am trying to optimize the code to get the case and owner information outside the for loop.

 

New to Apex development. Would appreciate some pointers on writing efficient SOQls outside the For loop in a trigger.

 

/* Trigger logic.. If transportation case type, and status = "awaiting internal response, case creator alias = "CS agents" and case owner = regional call center, MVC agent field = TASR agent, then assign then case back to the MVC agent *./

'

 

trigger TR_2 on Case (before update) {
   Case[] cases = Trigger.new;
   for (Case a:cases){ 
    string creatorid;
    string casecreatoriwdalias;
      String caseowner;
    string iWdAliasCaseOwner;
    String caseno;
    String err_msg = '';
    String MVCowner;
      String iWDMVCOwner;
                     
             creatorid = a.CreatedById;
          caseno = a.CaseNumber;
          
          case c = [select ownerid from case where casenumber = :caseno limit 1];
           caseowner = a.ownerid;
          MVCowner  = a.MVC_Owner__c;
    
         // get user alias information for the case creator   
    User userinfor = [select alias, iWD_Alias_Case_Owner__c, Iwd_Case_Creator__c from User where id = :creatorid];
    casecreatoriwdalias = userinfor.Iwd_Case_Creator__c;
    
      if (caseowner.substring(0,3) == '005'){
    // get case owner alias information
    User caseowneruserinfor = [select alias, iWD_Alias_Case_Owner__c, Iwd_Case_Creator__c from User where id = :caseowner limit 1];
    iWdAliasCaseOwner = caseowneruserinfor.iWD_Alias_Case_Owner__c;
     
     // check for status and SRCL Transportation record type and case owner and case creator alias
        if ((a.STATUS == 'Awaiting Internal Response'&& a.RecordTypeID == '012300000004rDZ')&& 
            (casecreatoriwdalias =='CAS' ||casecreatoriwdalias =='TASR/P1')&& 
                 (iWdAliasCaseOwner == 'DISP'|| iWdAliasCaseOwner == 'RCC'))  {
       a.IWD_Testing__c = 'trigger 2 enter the loop'; 
          }// status 'internal response'
                   
   if ((a.STATUS == 'Closed'&& a.RecordTypeID == '012300000004rDZ')&& 
            (MVCowner =='CAS' ||MVCowner =='TASR/P1')&& 
                 (iWdAliasCaseOwner == 'DISP'|| iWdAliasCaseOwner == 'RCC'))  {
       a.IWD_Testing__c = 'trigger2 working!!'; 
       a.ownerid = creatorid;  
       a.status = 'Awaiting internal response';   
        }// status 'closed'
                    } //if case owner 
      }// FOR LOOP
} // EOF

  • September 29, 2010
  • Like
  • 0

I need to implement the following; Based on the below criteria for case creatorID and case owner id, I want to display a message ( not a error message) stating " This case was created by a CAS agent. It will get reassigned to the case creator"). Right now my code displays an error message but the user has to go back to the case and change owner. 

 

Is there a way to display a message and change the ownerid automatically via the trigger?

 

if ((a.STATUS == 'Awaiting Internal Response'&& a.RecordTypeID == '012300000004rDZ')&&  
                     (casecreatoriwdalias =='CAS' ||casecreatoriwdalias =='TASR/P1')&&  
                       (iWdAliasCaseOwner == 'DISP'|| iWdAliasCaseOwner == 'RCC'))     {
                         a.IWD_Testing__c = 'trigger 2 enter the loop';    
                         a.iwd_check__c    = true;                        
                                }// status
                                
            if (a.iwd_check__c){
                   err_msg = 'Case opened by TASR/P1 or CAS Agent: Please assign it to:';
                   err_msg += casecreatoriwdalias + ' ' + a.CreatedById + '<br>';
                   a.addError(err_msg);

                   a.ownerid  = caseowner;
                             } 

 

 

Thanks

Chitra

  • September 22, 2010
  • Like
  • 0

Hi,

Just wondering if there are any system generated trace files in SFDC which might help with debugging or troubleshooting any code related issues.

 

  • July 09, 2010
  • Like
  • 0

Hi,

 

We are getting the following error when trying to deploy a trigger.

 

 

ACCFTriggerValidation.myTest()Class773Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, tgrBatchJobs: execution of BeforeInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com ...

 

The code snippet is attached. We are not sure why the batch upload fails and how we should index our fields. We are new to APEX so not sure how to get started.

 

// code snippet

//BATCH VALIDATION
      PreferredContact__c mycontact = new PreferredContact__c(Account__c=accounttest.id, preferredemail__C='user@site.com', preferredfax__c='3345567890');
      insert mycontact;
        
    PreferredIA__c testme = new PreferredIA__c(OKSendSurvey__c = true, account__c = accounttest.id, specialist__c = userid[0].id);
    insert testme;
    
    Batch_Job__c[] jobme = new batch_job__c[]{new Batch_Job__c(IsRunning__c = true, Description__c = 'test neutral', JobType__c = 'Test Email', DeleteMe__c = false),
                                           new Batch_Job__c(isRunning__c = true, Description__c = 'test positive', jobType__c = 'Send Surveys', DeleteMe__c = false),
                                            new Batch_Job__c(isRunning__c = true, Description__c = 'test positive', jobType__c = 'Send Surveys', DeleteMe__c = false)};
    insert jobme;
    
    jobme[0].Deleteme__c = true;

// error on line 77 column 3

    update jobme[0];
    
    jobme[1].Deleteme__c = true;
    update jobme[1];

  • July 09, 2010
  • Like
  • 0