function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Raymond MortuRaymond Mortu 

trigger validation error

Hi Guys, i got this error validating my Trigger

System.ListException: List index out of bounds: 1  Stack Trace: Class.CaseUtility.updateExpiredPoaLinks: line 582, column 1 Class.CaseUtilty_test.testUpdateExpiredPoaLinks: line 192, column

code below:
trigger t1 on Case (before insert, before update) {

 Group q = [SELECT Id FROM Group WHERE Name ='NCT queue' AND Type = 'Queue']; 

Contact con = new Contact(); 

for(Case cas : Trigger.New){

         if(cas.Court_Process__c == 'NCT'){

        cas.OwnerId = q.Id; 

 NCT__c nctNew = new NCT__c(Full_Name__c = con.cm1__Full_Name__c ); 

  insert nctNew; 

need help
Tiago Armando CoelhoTiago Armando Coelho
HI Raimound , 

The error doesn't seems to be in the trigger but in one related class like :

Please post the code lines that are raising errors.
Hi Raymond,
This means that your query has returned no records that match the criteria.  If you then attempt to access an element at row 2, this will throw an error as that row doesn't exist. Its good practice to check there are records first.
You need to share code for two methods mentioned in the error. 1) updateExpiredPoaLinks 2) testupdateExpiredPoaLinks

I see you are initializing a new contact record on line 5. and setting full name as
NCT__c nctNew = new NCT__c(Full_Name__c = con.cm1__Full_Name__c );
//at this point con.on.cm1__Full_Name__c  is empty.. or NULL rather.
Raymond MortuRaymond Mortu
Hi guys,
thanks for helping out:

Method for Class.CaseUtility​
public static void updateExpiredPoaLinks() {
      //String fname='poa/62097/original/POA_KERAPETSE_MOTSHOLATHEBE.pdf';
      //String newFname=AwsUtility.getSignedURL(fname);
      String newFname = '';
      List<String> urlParts = null;
      List<String> fnameParts = null;
      List<ParmState__c> ps = [Select State__c from ParmState__c where Name='CaseSMS'];
      ps[0].State__c = false;  
      update ps[0];

      List<Case> cases = [select Id, POA_URL__c from Case Where POA_URL__c <> '' order by LastModifiedDate asc limit 100];
      for (Case c : cases){
         urlParts = c.POA_URL__c.split('\\?');
         if (!urlParts[0].endsWith('/')) {
            fnameParts = urlParts[0].split('');
/*Line 582*/  newFname=AwsUtility.getSignedURL(fnameParts[1]);                 
            update c;
      ps[0].State__c = true;  
      update ps[0];
   global void execute(SchedulableContext sc)

Method for CaseUtilty_test.testUpdateExpiredPoaLinks​
static testMethod void testUpdateExpiredPoaLinks() {

/*Line 192*/  CaseUtility.updateExpiredPoaLinks();              
              system.assertEquals(0, 0);

Raymond MortuRaymond Mortu
Please ignore these:  /*<i><b>Line 192</b></i>*/
                                  /*<b>Line 582</b>

wanted to point out the line numbers