• sravan velama
  • NEWBIE
  • 104 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 32
    Replies
Hi All,

I am writing a test class for a batch class but my current code coverage is 0% and not able to cover. I am geetting error as:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [Account__c]
Batch class is as belows:
global class UpdatePickUpstatusBatch implements 
    Database.Batchable<sObject>, Database.Stateful {
    

    global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator('SELECT ID, Pickup_Date__c, Pickup_Status__c, Name FROM Pickup_Request__c Where Pickup_Date__c != null and Pickup_Status__c==\'Waitlisted\'');

    }

    global void execute(Database.BatchableContext bc, List<Pickup_Request__c> PRScope){
        // process each batch of records
        List<Pickup_Request__c> updateprlist = new List<Pickup_Request__c>();
        for (Pickup_Request__c pr : PRScope) {
           if(Date.today()==pr.Pickup_Date__c-Integer.valueof(Label.PickDateDaysforBatch))
           {
               pr.Pickup_Status__c = 'Open';
               updateprlist.add(pr);
                // make http callouts here Start
                
                
                // End              
           }
        }
        if(!updateprlist.IsEmpty()){
            update updateprlist;
        }
    }    

    global void finish(Database.BatchableContext bc){
        
    }    

}

My test class is as belows:
 
@isTest
public class UpdatePickUpstatusBatch_Test {
    static testMethod void UpdatePickUpstatusBatchtest1(){
    
    Schema.DescribeSObjectResult ACCobj1 = Schema.SObjectType.Account;
    Map<String,Schema.RecordTypeInfo> rtMapByName = ACCobj1 .getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtByName = rtMapByName.get('Site');
    ID ACCSiteRecTypeid = rtByName.getRecordTypeId(); 
    
    Schema.DescribeSObjectResult ACCobj2 = Schema.SObjectType.Account;
    Map<String,Schema.RecordTypeInfo> rtMapByName2 = ACCobj2 .getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtByName2 = rtMapByName2.get('Customer');
    ID ACCCustRecTypeid = rtByName2.getRecordTypeId(); 
    
    Schema.DescribeSObjectResult ACCobj3 = Schema.SObjectType.Account;
    Map<String,Schema.RecordTypeInfo> rtMapByName3 = ACCobj3 .getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtByName3 = rtMapByName3.get('Billing');
    ID ACCBillingRecTypeid = rtByName3.getRecordTypeId(); 
    
        
        
        Account AccRecCustomer = new Account();
            AccRecCustomer.Name = 'Acme';
            AccRecCustomer.Phone = '1234';            
            AccRecCustomer.RecordTypeId= ACCCustRecTypeid;
            AccRecCustomer.Password__c = 'test data';
            AccRecCustomer.Status__c = 'Active';
        insert AccRecCustomer;
        
        Account AccRec = new Account();
            AccRec.Name = 'Acme';
            AccRec.Phone = '1234';
            AccRec.Parent = AccRecCustomer;
        
           //AccRec.Parent =  AccRecCustomer.id;
            AccRec.Status__c = 'Active';
            AccRec.RecordTypeId= ACCSiteRecTypeid;
            AccRec.Password__c = 'test data';
        insert AccRec;
        
        Account AccRecBilling = new Account();
            AccRecBilling.Name = 'Acme';
            AccRecBilling.Parent = AccRecCustomer;
            AccRecBilling.Phone = '1234';
            AccRecBilling.Status__c = 'Active';
            AccRecBilling.RecordTypeId= ACCBillingRecTypeid;
            
        insert AccRecBilling;

               
        Contact ConRec = new Contact();
            ConRec.FirstName = 'John';
            ConRec.LastName = 'Smith';
            ConRec.Phone = '1234';
            ConRec.Email = 'abc@gmail.com';
            
        insert ConRec;
        
         Contact ConRec1 = new Contact();
            ConRec1.FirstName = 'John1';
            ConRec1.LastName = 'Smith1';
            ConRec1.Phone = '12345';
            ConRec1.Email = 'abc1@gmail.com';
            
        insert ConRec1;
        
        Address__c AddRec = new Address__c();
            AddRec.Address1__c = 'G  370 Docklands Dr';
            AddRec.Country__c = 'AUSTRALIA';
            AddRec.State__c = 'VIC';
            AddRec.Suburb__c = 'Docklands';
            AddRec.Zipcode__c = 3008;
            AddRec.Shipping_Address_Validation_Status__c = 'Verified by Experian';
            AddRec.Shipping_Address_Validation_Timestamp__c = system.today();
            
        Insert AddRec;
        String AddRecId = AddRec.id; 
        CustAddrAssoc__c  CustAddRec = new CustAddrAssoc__c ();
            CustAddRec.Account__c = AccRec.id;
            CustAddRec.Address__c = AddRec.id; 
            CustAddRec.Type__c = 'Site';
            CustAddRec.InActive__c = false;
        
        Insert CustAddRec;
        
        Suburbs__c  SuburRec = new Suburbs__c ();
            SuburRec.Name = 'DOCKLANDS';
            SuburRec.Post_Code__c = '3008';
            SuburRec.State__c = 'VIC';
            SuburRec.Depot__c = 'MEL';
            SuburRec.City__c = '818 Bourke Street';
         
        insert SuburRec; 
        
        Holiday__c  HolRec = new Holiday__c ();
            HolRec.Name = 'ADELAIDE CUP DAY';
            HolRec.Type__c = 'Normal';
            HolRec.State_Name__c = 'VIC';
            HolRec.Start_Date__c = System.today();
            HolRec.End_Date__c = System.today()+2;
        Insert HolRec ;
        
        Pickup_Request__c  PickReqRec = new Pickup_Request__c();
        
           /** PickReqRec.Pickup_Type__c = 'Pickup';
            PickReqRec.Pickup_Status__c = 'Draft';
            PickReqRec.Source__c = 'Email';
            PickReqRec.Third_Party_Contact__c = ConRec1.id;
            PickReqRec.Contact__c = ConRec.id;
            PickReqRec.Billing_A_c__c = AccRecBilling.id;
            PickReqRec.Ready_Time__c = '12:00';
            PickReqRec.Close_Time__c = '19:00';
            PickReqRec.SuburbT__c = 'DOCKLANDS';
            PickReqRec.Pickup_Date__c = System.today()+1;
            PickReqRec.State__c = 'test Sate';
            PickReqRec.Service__c ='Priority';
            PickReqRec.Total_Wt__c = 3000;
            //PickReqRec.Address__c = AddRec.id;
            PickReqRec.password__c = 'test data';
            
        Insert PickReqRec;**/
       
            PickReqRec.Pickup_Type__c = 'Pickup';
            PickReqRec.Pickup_Status__c = 'Waitlisted';
            PickReqRec.Source__c = 'Email';
            PickReqRec.Third_Party_Contact__c = ConRec1.id;
            PickReqRec.Contact__c = ConRec.id;
            PickReqRec.Billing_A_c__c = AccRecBilling.id;
            PickReqRec.Ready_Time__c = '12:00';
            PickReqRec.Close_Time__c = '19:00';
            PickReqRec.SuburbT__c = 'DOCKLANDS';
            PickReqRec.Pickup_Date__c = System.today()+1;
            PickReqRec.State__c = 'test Sate';
            PickReqRec.Service__c ='Priority';
            PickReqRec.Total_Wt__c = 3000;
            PickReqRec.Address__c = CustAddRec.id;
            PickReqRec.password__c = 'test data';
            PickReqRec.Destination_SuburbL__c = SuburRec.id;
            PickReqRec.H_cm__c = 444;
            PickReqRec.Item_Description__c ='Item';
            PickReqRec.L_cm__c = 44;
            PickReqRec.No_of_Items__c =4;
            PickReqRec.Customer__c = AccRecCustomer.id;
            //PickReqRec.Customer__c = AccRec.id;
        	PickReqRec.Account__c =AccRec.id;

            PickReqRec.W_cm__c = 400;
            PickReqRec.Food_Stuff__c  = 'Yes';
            
        Insert PickReqRec;
        
        
       
        Pickup_Request__c PickReqRecObj = [Select id ,Pickup_Status__c ,Pickup_Date__c from Pickup_Request__c  where id =:PickReqRec.id LIMIT 1];
        
        System.debug('----->'+PickReqRecObj );

        //PickReqRec.Pickup_Status__c = 'Open';
        //update PickReqRec;
        
        Test.startTest();

        UpdatePickUpstatusBatch UpdateBatch = new UpdatePickUpstatusBatch();
          //DataBase.executeBatch(UpdateBatch);
        ID batchprocessid = Database.executeBatch(UpdateBatch);
        Test.stopTest();
    }
}

Below is the look up filter:
Object-Pickup Request
Field label: Site
Field API: Account__c
User-added image

When I removed the filter then my code coverage becomes 72% but that is not a correct approach. I need not have to remove the filter infact I do need to cover the same in my test class which I am not getting.

Kindly help me

Thanks & Regards,
Harjeet
 
i am trying to create contact upon account insertion
public static Account createContact()
   {   List<account> acc= new List<Account>();
       for(Account a : Trigger.new)
       {
       Contact c=new Contact();
       C.LastName='Sharma';
       c.Description=a.name;
       acc.add(c);
       } 
        insert acc;     
   }
but there is error    
unexpected token: 'Account'
How to write a test class for a queuable class which allows callouts where callout method has future annotation and the queueable class is invoked from trigger. I am getting data uncommiteed issue. How to resolve it?
Hi All

How can i copy/insert record form multiple object to one custom object uisng batch process.I have created batch class but its bring data from one object to another object ..
global class CopyContact implements Database.Batchable<Contact> {

    global CopyContact (){}

    global List<Contact> start(Database.BatchableContext BC) {
        return [Select Name,Email,Phone,MobilePhone From Contact];
    }
    
    

    global void execute(Database.BatchableContext BC, List<Contact> scope) {
       List<Master_Data__c> lhList = new List<Master_Data__c>();
       for(Contact lh : scope){
           lhList.add(
               new Master_Data__c(
                  Name=lh.Name,Email__c=lh.Email,Phone__c=lh.Phone,Mobile__c=lh.MobilePhone
               )
           );
       }
       insert lhList;
    }

    global void finish(Database.BatchableContext BC) {}
}

 
Hi Friends,
My JSOn is - {"InvalidData"{"userType":null,"status":"success","sessionToken":null,"name":null,"message":"success","mappingId":null,"emailId":null,"data":null,"code":1000}}

But VF is returning - {&quot;InvalidData&quot;:{&quot;userType&quot;:null,&quot;status&quot;:&quot;success&quot;,&quot;sessionToken&quot;:null,&quot;name&quot;:null,&quot;message&quot;:&quot;success&quot;,&quot;mappingId&quot;:null,&quot;emailId&quot;:null,&quot;data&quot;:null,&quot;code&quot;:1000}}


So how to remove this &quot so that I can get the correct JSON as per my class.

My method is as below:
****************************
@RemoteAction
    global static String inValid(integer dataId,boolean contactValid, boolean productValid,
                                 boolean actionValid,String other){
      
       integer contact = 0;
       integer action = 0;
       integer product = 0;
       if(contactValid == true){
        contact = 1;                
       }
       if(productValid == true){
        product = 1;
       }
       if(actionValid == true){
        action = 1;
       }

       SalesAIRecommendations.Item response = new SalesAIRecommendations.Item();
        Recommendation__c recommendation = [SELECT Id,Recom_External_Id__c,Feedback__c FROM Recommendation__c where Recom_External_Id__c =: dataId];
                                            
        if(recommendation != null){
            system.debug('valid recommendation Id');
            recommendation.Feedback__c = other;
            update recommendation;
          
            Invalid_Recommendation__c invRec = new Invalid_Recommendation__c();
            invRec.Recommendation_ID__c = recommendation.Recom_External_Id__c;
            invRec.productChange__c = product;
            invRec.Next_Best_Action__c = action;
            invRec.contactId__c = contact;
            invRec.Others__c = recommendation.Feedback__c;
            insert invRec;
            response.status='success';
            response.code=1000;
            response.message = 'success';
          
            system.debug('{"InvalidData":' + JSON.serialize(response) + '}');
            return '{"InvalidData":' + JSON.serialize(response) + '}';
        }
        else{
            system.debug('invalid recommendation Id');   
            response.status='failure';
            response.code=1001;
            response.message = 'failure';
            system.debug('******:'  + '{"InvalidData":' + JSON.serialize(response) + '}');
            return '{"InvalidData":' + JSON.serialize(response) + '}';
                        
              }
    }
 
  • August 31, 2017
  • Like
  • 0
Hi there,

How many records can save using save method of StandardSetController.

I try with 10111 records, but there is no governor error found.

there is debug source...
List<TestObj__c> saveRecordList = new List<TestObj__c>();

String queryStr = 'Select id, Name, TestField__c From TestObj__c limit 10111';

ApexPages.StandardSetController saveRecordListSetCon = null;

saveRecordListSetCon = new ApexPages.StandardSetController(Database.query(queryStr));

saveRecordListSetCon.setPageSize(10111);

saveRecordList = saveRecordListSetCon.getRecords();

for(TestObj__c r : saveRecordList ){
    r.TestField__c = 'test10111';
}

saveRecordListSetCon.save();

Regards,
LinThaw
I'm trying to generate random geolocation codes and assign them to a record when it is created, These records are simply dummy data to use for testing purposes but for my test to work properly I need to set random geolocation codes. Here is what I have so far, but I can't get the geocode to generate:
 
List<Location__c> locat = new List<Location__c>();
for (Integer a = 0; a <5; a++) {
  locat.add(new Location__c(Location_Name__c = 'Location ' + a ));
   
	locat.GeoCode__Latitude__s = getRandomInteger();
    locat.GeoCode__Longitude__s = getRandomLong();
}

insert locat;

 
I'm having an issue with a test class and I think the error is that it's not inserting some setup objects that are required. How can I make sure that the objects are inserted? Is there a method like System.Assert to achieve this?
Hi All,

I am writing a test class for a batch class but my current code coverage is 0% and not able to cover. I am geetting error as:
System.DmlException: Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [Account__c]
Batch class is as belows:
global class UpdatePickUpstatusBatch implements 
    Database.Batchable<sObject>, Database.Stateful {
    

    global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator('SELECT ID, Pickup_Date__c, Pickup_Status__c, Name FROM Pickup_Request__c Where Pickup_Date__c != null and Pickup_Status__c==\'Waitlisted\'');

    }

    global void execute(Database.BatchableContext bc, List<Pickup_Request__c> PRScope){
        // process each batch of records
        List<Pickup_Request__c> updateprlist = new List<Pickup_Request__c>();
        for (Pickup_Request__c pr : PRScope) {
           if(Date.today()==pr.Pickup_Date__c-Integer.valueof(Label.PickDateDaysforBatch))
           {
               pr.Pickup_Status__c = 'Open';
               updateprlist.add(pr);
                // make http callouts here Start
                
                
                // End              
           }
        }
        if(!updateprlist.IsEmpty()){
            update updateprlist;
        }
    }    

    global void finish(Database.BatchableContext bc){
        
    }    

}

My test class is as belows:
 
@isTest
public class UpdatePickUpstatusBatch_Test {
    static testMethod void UpdatePickUpstatusBatchtest1(){
    
    Schema.DescribeSObjectResult ACCobj1 = Schema.SObjectType.Account;
    Map<String,Schema.RecordTypeInfo> rtMapByName = ACCobj1 .getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtByName = rtMapByName.get('Site');
    ID ACCSiteRecTypeid = rtByName.getRecordTypeId(); 
    
    Schema.DescribeSObjectResult ACCobj2 = Schema.SObjectType.Account;
    Map<String,Schema.RecordTypeInfo> rtMapByName2 = ACCobj2 .getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtByName2 = rtMapByName2.get('Customer');
    ID ACCCustRecTypeid = rtByName2.getRecordTypeId(); 
    
    Schema.DescribeSObjectResult ACCobj3 = Schema.SObjectType.Account;
    Map<String,Schema.RecordTypeInfo> rtMapByName3 = ACCobj3 .getRecordTypeInfosByName();
    Schema.RecordTypeInfo rtByName3 = rtMapByName3.get('Billing');
    ID ACCBillingRecTypeid = rtByName3.getRecordTypeId(); 
    
        
        
        Account AccRecCustomer = new Account();
            AccRecCustomer.Name = 'Acme';
            AccRecCustomer.Phone = '1234';            
            AccRecCustomer.RecordTypeId= ACCCustRecTypeid;
            AccRecCustomer.Password__c = 'test data';
            AccRecCustomer.Status__c = 'Active';
        insert AccRecCustomer;
        
        Account AccRec = new Account();
            AccRec.Name = 'Acme';
            AccRec.Phone = '1234';
            AccRec.Parent = AccRecCustomer;
        
           //AccRec.Parent =  AccRecCustomer.id;
            AccRec.Status__c = 'Active';
            AccRec.RecordTypeId= ACCSiteRecTypeid;
            AccRec.Password__c = 'test data';
        insert AccRec;
        
        Account AccRecBilling = new Account();
            AccRecBilling.Name = 'Acme';
            AccRecBilling.Parent = AccRecCustomer;
            AccRecBilling.Phone = '1234';
            AccRecBilling.Status__c = 'Active';
            AccRecBilling.RecordTypeId= ACCBillingRecTypeid;
            
        insert AccRecBilling;

               
        Contact ConRec = new Contact();
            ConRec.FirstName = 'John';
            ConRec.LastName = 'Smith';
            ConRec.Phone = '1234';
            ConRec.Email = 'abc@gmail.com';
            
        insert ConRec;
        
         Contact ConRec1 = new Contact();
            ConRec1.FirstName = 'John1';
            ConRec1.LastName = 'Smith1';
            ConRec1.Phone = '12345';
            ConRec1.Email = 'abc1@gmail.com';
            
        insert ConRec1;
        
        Address__c AddRec = new Address__c();
            AddRec.Address1__c = 'G  370 Docklands Dr';
            AddRec.Country__c = 'AUSTRALIA';
            AddRec.State__c = 'VIC';
            AddRec.Suburb__c = 'Docklands';
            AddRec.Zipcode__c = 3008;
            AddRec.Shipping_Address_Validation_Status__c = 'Verified by Experian';
            AddRec.Shipping_Address_Validation_Timestamp__c = system.today();
            
        Insert AddRec;
        String AddRecId = AddRec.id; 
        CustAddrAssoc__c  CustAddRec = new CustAddrAssoc__c ();
            CustAddRec.Account__c = AccRec.id;
            CustAddRec.Address__c = AddRec.id; 
            CustAddRec.Type__c = 'Site';
            CustAddRec.InActive__c = false;
        
        Insert CustAddRec;
        
        Suburbs__c  SuburRec = new Suburbs__c ();
            SuburRec.Name = 'DOCKLANDS';
            SuburRec.Post_Code__c = '3008';
            SuburRec.State__c = 'VIC';
            SuburRec.Depot__c = 'MEL';
            SuburRec.City__c = '818 Bourke Street';
         
        insert SuburRec; 
        
        Holiday__c  HolRec = new Holiday__c ();
            HolRec.Name = 'ADELAIDE CUP DAY';
            HolRec.Type__c = 'Normal';
            HolRec.State_Name__c = 'VIC';
            HolRec.Start_Date__c = System.today();
            HolRec.End_Date__c = System.today()+2;
        Insert HolRec ;
        
        Pickup_Request__c  PickReqRec = new Pickup_Request__c();
        
           /** PickReqRec.Pickup_Type__c = 'Pickup';
            PickReqRec.Pickup_Status__c = 'Draft';
            PickReqRec.Source__c = 'Email';
            PickReqRec.Third_Party_Contact__c = ConRec1.id;
            PickReqRec.Contact__c = ConRec.id;
            PickReqRec.Billing_A_c__c = AccRecBilling.id;
            PickReqRec.Ready_Time__c = '12:00';
            PickReqRec.Close_Time__c = '19:00';
            PickReqRec.SuburbT__c = 'DOCKLANDS';
            PickReqRec.Pickup_Date__c = System.today()+1;
            PickReqRec.State__c = 'test Sate';
            PickReqRec.Service__c ='Priority';
            PickReqRec.Total_Wt__c = 3000;
            //PickReqRec.Address__c = AddRec.id;
            PickReqRec.password__c = 'test data';
            
        Insert PickReqRec;**/
       
            PickReqRec.Pickup_Type__c = 'Pickup';
            PickReqRec.Pickup_Status__c = 'Waitlisted';
            PickReqRec.Source__c = 'Email';
            PickReqRec.Third_Party_Contact__c = ConRec1.id;
            PickReqRec.Contact__c = ConRec.id;
            PickReqRec.Billing_A_c__c = AccRecBilling.id;
            PickReqRec.Ready_Time__c = '12:00';
            PickReqRec.Close_Time__c = '19:00';
            PickReqRec.SuburbT__c = 'DOCKLANDS';
            PickReqRec.Pickup_Date__c = System.today()+1;
            PickReqRec.State__c = 'test Sate';
            PickReqRec.Service__c ='Priority';
            PickReqRec.Total_Wt__c = 3000;
            PickReqRec.Address__c = CustAddRec.id;
            PickReqRec.password__c = 'test data';
            PickReqRec.Destination_SuburbL__c = SuburRec.id;
            PickReqRec.H_cm__c = 444;
            PickReqRec.Item_Description__c ='Item';
            PickReqRec.L_cm__c = 44;
            PickReqRec.No_of_Items__c =4;
            PickReqRec.Customer__c = AccRecCustomer.id;
            //PickReqRec.Customer__c = AccRec.id;
        	PickReqRec.Account__c =AccRec.id;

            PickReqRec.W_cm__c = 400;
            PickReqRec.Food_Stuff__c  = 'Yes';
            
        Insert PickReqRec;
        
        
       
        Pickup_Request__c PickReqRecObj = [Select id ,Pickup_Status__c ,Pickup_Date__c from Pickup_Request__c  where id =:PickReqRec.id LIMIT 1];
        
        System.debug('----->'+PickReqRecObj );

        //PickReqRec.Pickup_Status__c = 'Open';
        //update PickReqRec;
        
        Test.startTest();

        UpdatePickUpstatusBatch UpdateBatch = new UpdatePickUpstatusBatch();
          //DataBase.executeBatch(UpdateBatch);
        ID batchprocessid = Database.executeBatch(UpdateBatch);
        Test.stopTest();
    }
}

Below is the look up filter:
Object-Pickup Request
Field label: Site
Field API: Account__c
User-added image

When I removed the filter then my code coverage becomes 72% but that is not a correct approach. I need not have to remove the filter infact I do need to cover the same in my test class which I am not getting.

Kindly help me

Thanks & Regards,
Harjeet
 
i am trying to create contact upon account insertion
public static Account createContact()
   {   List<account> acc= new List<Account>();
       for(Account a : Trigger.new)
       {
       Contact c=new Contact();
       C.LastName='Sharma';
       c.Description=a.name;
       acc.add(c);
       } 
        insert acc;     
   }
but there is error    
unexpected token: 'Account'
Hello Friends,
 
My requirement is that, i need to display org metadata components (like objecta,apex classes, vf pages, record types, profiles, permisstion sets ...etc) on my VF page.

here i know i am able to petch objects metadata through Schema , but how to petch remaing metadata componets?Can you please let me know where i am going petch metadata and display my vf page.

public List<SelectOption> getName(){
  List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();     
  List<SelectOption> options = new List<SelectOption>();
for(Schema.SObjectType f : gd)
  {
    options.add(new SelectOption(f.getDescribe().getLabel(),f.getDescribe().getLabel()));
 }
 return options;
 }

Any help/guidance would be highly appreciated!!
 
Many Thanks,
Naresh j
Hi,
I have 2 Date/Time fields.
I want to throw a validation rule if 'Time' in one Date/time field is lesser than another Date/time field. 
I only want to check the time difference not the date. Could you please help me.
HI All
I have two custom object Object1 and Object2 and both have relationship.When I am creating Object2 record with lookup field value of object1 ,need to update record owner of object2 with object1 after record save.i have created a trigger but facing problem like

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger SyncField caused an unexpected exception, contact your administrator: SyncField: data changed by trigger for field Owner ID: id value of incorrect type: a0b0k000000sivZAAQ
 
trigger SyncField on Object2__c (before insert, before update) {
  for(Object2__c ao:Trigger.new)                                    
    if(Trigger.isInsert)                                             
      ao.OwnerId = ao.object1__c;                                   
    else                                                            
      if(ao.OwnerId != Trigger.oldMap.get(ao.id).OwnerId)         
        ao.object1__c= ao.OwnerId;                                 
      else                                                           
        if(ao.object1__c!= Trigger.oldMap.get(ao.id).object1__c)  
          ao.OwnerId = ao.object1__c;                               
}

 
Hi, I would like to get some information or sample code about how to read an external file (ie. pdf file) which is located at AWS S3. I´ve already know there is a toolkit to do that, but I also found out that Amazon has deprecated SOAP for their services and it would be sooner or later when they decide not to support anymore new SOAP request (now for example they do it only in https calls and said they won't updgrade SOAP methods, according to their documentation).

Any help on this with some sample code would be appreciated.