• Oleg Ishchuk
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 7
    Replies
Hello, everyone! I have following part of code:
User-added imageWhen I validate code during deployment I get errors. Errors are - 'System.ListException: List index out of bounds: 0' on line 77. When I try to use this code using an anonymous block, the accountLayout gets the first component. But during deployment, it seems like Metadata.Layout isn't visible. How can I solve this issue? 
Hello, everyone! I have following part of code:
User-added imageWhen I validate code during deployment I get errors. Errors are - 'System.ListException: List index out of bounds: 0' on line 77. When I try to use this code using an anonymous block, the accountLayout gets the first component. But during deployment, it seems like Metadata.Layout isn't visible. How can I solve this issue? 
Controller:
public class BankAccuont_TransactionStatus {
    public static void TransactionStatus(){
            List<Bank_Account__c> BankList = new List<Bank_Account__c>();
            List<Bank_Account__c> BList=[select id,Name,Account_Type__c,Number_Of_Transaction__c,Status__c from Bank_Account__c];
        for(Bank_Account__c b:BList){
            Bank_Account__c baccnt = new Bank_Account__c();
            if(b.Account_Type__c =='Current' && b.Number_Of_Transaction__c <=5){
                    baccnt.Status__c = 'Red';                  
                }
                else if(b.Account_Type__c=='Current' && b.Number_Of_Transaction__c == 6 || b.Number_Of_Transaction__c ==10){
                    baccnt.Status__c = 'Yellow';                    
                } 
            else if(b.Account_Type__c=='Current' && b.Number_Of_Transaction__c >= 10){
                    baccnt.Status__c = 'Green';
            }
            BankList.add(baccnt);            
        }
      // update BankList;
                
    }
}
=====================================================
trigger:
trigger Update_Status_Based_On_Transactions on Bank_Account__c (after insert,after update) {
    
    BankAccuont_TransactionStatus.TransactionStatus(trigger.new);
}
Hi All,
Need help with below test case

@isTest

private class TestTimecardManager{

@testSetup static void setup()
{
Contact conct = new contact(FirstName='Test', LastName='TestLastName', Phone='4565465789');

insert conct;

Project__c prj = new Project__c(Name ='MyProject');

insert prj;
}

@isTest static void TestInserMethodValid()
{

//code to access contact and project objects

Assignment__c assign = new Assignment__c(Contact__c=conct.Title,Project__c='MyProject',Start_Date__c=Date.parse('01/01/2019'),End_Date__c=Date.parse('10/01/2019'));

}
}


As you see I need to access the contact and project object in TestInserMethodValid() method.

Need your help!.