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
BathrugBathrug 

INACTIVE_OWNER_OR_USER. operation performed with inactive user.

Hi everyone , 

Im an apex noob,  and have just started a position in a company that uses salesforce for its CRM,  Unfortunately my predecessor left without handing over the salesforce reigns and I have been tasked with trying to change an email address in the code.  However when i change the address and try to reupload the code,  it goes to the sandbox without any problems,  however when it goes to the production server I get the message that there is a system Dml exception due to an inactive owner or user.  I have checked salesforce for the status of those that wrote the original code and they are all down as active ( despite being no longer with the company )..  The error seams to come in the testing code.

I would like to teach myself salesforce development however this one error is a giant brick wall to me. I have posted the code below,  can anybody give me some pointers in how to overcome this.

 

@isTest
private class vf_testing {

    static testMethod void myUnitTestofmultiple() {
        // TO DO: implement unit test
        caserefs igor = new caserefs();
        igor.caser='123';
        igor.poster='456';
     }
     
     static testMethod void testingextra_dates(){
     Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Business_Unit__c='Motor', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     Opportunity rei =[select id, name, estimatediscovery__c, account.personmailingstreet, account.PersonMailingCity, account.personmailingstate, account.personmailingpostalcode, Insurer_prefix__c, insurer__c, Case_referral_type__c, Business_Unit__c, case_file_long_reference__c, StageName, Date_of_Loss__c, AccountId from opportunity where id=:barney.id];
     system.debug(rei.case_file_long_reference__c);
     ApexPages.StandardController pebbles=new ApexPages.StandardController(rei);
     extra_dates_opp bambam = new extra_dates_opp(pebbles);
     bambam.setappDriskAddr(false);
     bambam.setappDstreet('Street name');
     String name=bambam.getappDstreet();
     bambam.setappDcity('Street name');
     name=bambam.getappDcity();
     bambam.setappDcounty('Street name');
     name=bambam.getappDcounty();
     bambam.setappDpostcode('Street name');
     name=bambam.getappDpostcode();
     bambam.setappDuk('Street name');
     name=bambam.getappDuk();
     boolean isaddr=bambam.getappDriskaddr();
     bambam.setappDriskAddr(true);
     name=bambam.getappDstreet();
     name=bambam.getappDcity();
     name=bambam.getappDcounty();
     name=bambam.getappDpostcode();
     bambam.setappDstreet('Street name');
     bambam.setappDcity('Street name');
     bambam.setappDcounty('Street name');
     bambam.setappDpostcode('Street name');
     bambam.setappDcircs('Event');
     name=bambam.getappDcircs();
     name=bambam.getincidentwords();
     bambam.setincidentwords('incidentwords');
     name=bambam.getHTMLinfo();
     PageReference bexbex=bambam.PDFHH14();
     name=bambam.getapprox();
     name=bambam.getlongdate();
     name=bambam.getlossdate();
     bambam.nullme();
     PageReference nowhere=bambam.pdfme();
     name=bambam.getInsDial();
     name=bambam.getInsFormal();
     name=bambam.chooseInsName('EC');
     name=bambam.Choose0845('EC');
     name=bambam.chooseInsName('KG');
     name=bambam.Choose0845('KG');
     name=bambam.chooseInsName('MG');
     name=bambam.Choose0845('MG');
     name=bambam.chooseInsName('EI');
     name=bambam.Choose0845('EI');
     name=bambam.chooseInsName('CS');
     name=bambam.Choose0845('CS');
     name=bambam.chooseInsName('HS');
     name=bambam.Choose0845('HS');
     name=bambam.chooseInsName('RS');
     name=bambam.Choose0845('RS');
     name=bambam.chooseInsName('EQ');
     name=bambam.Choose0845('EQ');
     name=bambam.ChooseInsName('EM');
     name=bambam.Choose0845('EM');
     name=bambam.chooseInsName('HT');
     name=bambam.Choose0845('HT');
     name=bambam.Choose0845('EP');
     name=bambam.chooseInsName('XX');
     name=bambam.Choose0845('XX');
     name=bambam.gettype_of_incident();
     name=bambam.gettype_of_hhincident();
     name=bambam.incwords('MAD');
     name=bambam.incwords('SANE');
     name=bambam.hhincwords('HAL');
     name=bambam.hhincwords('HAD');
     name=bambam.hhincwords('HUM');
     }
     
     static testMethod void testingmulti_insert(){
     	Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     String caseref=Barney.Claim_Ref__c;
     system.debug(caseref);
     system.debug(Barney.Case_file_long_reference__c);
     	multi_insert pile=new multi_insert();
     	RecordTypeListCon types=new RecordTypeListCon();
     	types.sObjectType='Account';
     	List<SelectOption> screed=pile.gettypes();
     	screed=types.getItems();
     	pile.setSubject('Subjective');
     	String subj=pile.getSubject();
     	PageReference nowhere=pile.cancel();
     	boolean tick=pile.getDocreturns();
     	pile.setDocreturns(tick);
     	pile.addrow();
     	pile.removerow();
     	pile.cases[0].caser=caseref;
     	pile.cases[0].docser=true;
     	pile.docReturns=true;
     	pile.save();
     	pile.savepost();
     	pile.saveemail();
     	pile.clearout();
     	//Split here as the SOQL count is getting high.
     }
     
     static testMethod void testingmulti_insert2(){
     	Account Fred = new Account(LastName='Flintstoned');
     insert Fred;
     ID whom=Fred.Id;
     Account kgm = new Account(Name='KGM');
     insert kgm;
     ID insurer=kgm.id;
     Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());
     insert Barney;
     String caseref=Barney.Claim_Ref__c;
     system.debug(caseref);
     system.debug(Barney.Case_file_long_reference__c);
     	multi_insert pile=new multi_insert();
     	pile.cases[0].caser='bogus';
     	pile.save();
     	pile.cases[0].caser='430640';
     	pile.setSubject('Documents Received');
     	pile.save();
     	pile.outg();
     	pile.setSubject('1st Class Post');
     	pile.redticket=true;
     	pile.outg();
     	pile.setSubject('2nd Class Post');
     	pile.outg();
     	pile.setSubject('1st Class Packet');
     	pile.outg();
     	pile.numitems=1;
     	pile.totalcost=10.0;
     	pile.docReturns=true;
     	pile.outg();
     }
     
}

 It seams to bounce its issue against 

testingmulti_insert

                     SystemDmlException:Insert failed: First exception on row 1; first error:INACTIVE_OWNER_OR_USER. operation performed with inactive user.

                                                   Class.multi_insert.saveemail:line 176, column 1

 

Any help would be greatly and desperately appreciated

 

:)

 

Note : even if i change nothing and trying to send it back to the server I get the same error.

k_bentsenk_bentsen

Hmm, I actually do think the issue is stemming from the multi_insert class. Can you post that as well?

BathrugBathrug

heres the Multi_insert class as requested

 

 

public class multi_insert {
      
    public List<Task> tasks ;
    public List<caserefs> cases {get; set;}
    public String Subject;
    public String notes;
    public Boolean docReturns;
    public Boolean redticket {get; set;}
    public integer numitems {get; set;}
    public decimal totalcost {get; set;}
                     
    public List<SelectOption> gettypes() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('','--Select Record Type --'));
        options.add(new SelectOption('No contact letter','No contact letter'));
        options.add(new SelectOption('Rebook letter','Rebook letter'));
        options.add(new SelectOption('7 day letter','7 day letter'));
        options.add(new SelectOption('14 day letter','14 day letter'));
        options.add(new SelectOption('Documents Received','Documents Received'));
        options.add(new SelectOption('1st class letter','1st class letter'));
        options.add(new SelectOption('Registered letter','registered letter'));
        options.add(new SelectOption('2nd class letter','2nd class letter'));
        options.add(new SelectOption('Special Delivery','Special Delivery'));
        options.add(new SelectOption('Sent introduction letter','Sent Intro Letter'));
        options.add(new SelectOption('Sent 1st No contact letter','Sent 1st No contact letter'));
        options.add(new SelectOption('Sent 2nd No contact letter','Sent 2nd No contact letter'));
        options.add(new SelectOption('Report Sent','Report Sent'));
        options.add(new SelectOption('TLC Rejection','TLC Rejection'));
        options.add(new SelectOption('Property List','Property List'));
        return options;
        
    }
            
    public String getSubject() {
        return Subject;
    }
    
    public void setSubject(String Subject) {
        this.Subject= Subject;
    }
    
        public boolean getdocReturns() {
        return docReturns;
    }
    
    public void setdocReturns(Boolean docReturns) {
        this.docReturns= docReturns;
    }
        
    public multi_insert(){             
        tasks= new List<Task>();
        cases= new List<caserefs>();
        docReturns= false; 
        tasks.add(new Task());
        cases.add(new caserefs());
        cases.add(new caserefs());
        cases.add(new caserefs());
        cases.add(new caserefs());
        cases.add(new caserefs());
    }       

    public void addrow(){
        if(cases.size()<10)
             cases.add(new caserefs());    
    }     
    
    public void removerow(){  
        Integer i = cases.size();      
        cases.remove(i-1);    
    }        
    
    public void clearout(){
        //Nuke the cases
        cases.clear();
        cases.add(new caserefs());
        cases.add(new caserefs());
        cases.add(new caserefs());
        cases.add(new caserefs());
        cases.add(new caserefs());
    }

        public PageReference savepost(){
                //This function processes a list of post logging.
                Integer count = cases.size();
                //Create a list of opportunities to update.
                List<Opportunity>parole = new Opportunity[]{};
        Integer i = 0;  
        Integer k = -1;          
            do {
                List<Opportunity> holdingpen=[SELECT id, name, accountid from opportunity where Claim_Ref__c = :cases[i].caser limit 1];
                if(holdingpen.size()==1)
                {
                        Opportunity cell=holdingpen.get(0);
                        holdingpen.clear();
                        tasks.add(new Task());
                        k++;
                        tasks[k].whatID=cell.id;
                        cases[i].policyholder=cell.name;
                        tasks[k].Subject='Post received';
                        tasks[k].description='Received';
                        if(cases[i].docser==true) {
                                //Docs received is ticked
                                tasks[k].description=tasks[k].Description+' documents, ';
                        }
                        if(cases[i].keyser!=null) {
                                //Keys is filled in
                                tasks[k].description=tasks[k].Description+' '+cases[i].keyser+' keys,';
                        }
                        if(cases[i].itemser!=null) {
                                //An item is filled in
                                tasks[k].description=tasks[k].Description+' '+cases[i].itemser+',';
                                cell.Date_Documents_Received__c=date.today();
                                update cell;
                        }
                        //All cases
                        tasks[k].description=tasks[k].Description+' passed to '+cases[i].handler+'.';
                        tasks[k].ownerID=UserInfo.getuserid();
                        tasks[k].status='Completed';
                        tasks[k].activitydate=system.today();
                        ID relation=[Select id from Contact where accountid= :cell.accountid limit 1].id;
                        tasks[k].whoid=relation;
                 }
                else
                {
                        //we did not find it.
                        cases[i].policyholder='CLAIM NOT FOUND';
                }
                i++;
                } while (i < count);
                         
            insert tasks; 
            //Get rid of the tasks as they have IDs.                        
            tasks.clear() ;
            // nuke the whole darn thing
        PageReference home = new PageReference('/apex/PostLogging');        
        //home.setRedirect(true);        
        return home;
        }      
        
        //Household Email version
        public PageReference saveemail(){
                //This function processes a list of post logging.
                Integer count = cases.size();
                //Create a list of opportunities to update.
                List<Opportunity>parole = new Opportunity[]{};
        Integer i = 0;  
        Integer k = -1;          
            do {
                List<Opportunity> holdingpen=[SELECT id, name, accountid, ownerid from opportunity where Claim_Ref__c = :cases[i].caser limit 1];
                if(holdingpen.size()==1)
                {
                        Opportunity cell=holdingpen.get(0);
                        holdingpen.clear();
                        tasks.add(new Task());
                        k++;
                        tasks[k].whatID=cell.id;
                        cases[i].policyholder=cell.name;
                        tasks[k].Subject='Documents received by Email';
                        tasks[k].description='Received ' +cases[i].itemser + ', ' + 'saved to scanstore. Please acknowledge';
                        tasks[k].ownerID=cell.OwnerId;
                        tasks[k].status='Not Started';
                        tasks[k].activitydate=system.today();
                        ID relation=[Select id from Contact where accountid= :cell.accountid limit 1].id;
                        tasks[k].whoid=relation;
                        cell.Date_Documents_Received__c=date.today();
                        update cell;
                }
                else
                {
                        //we did not find it.
                        cases[i].policyholder='CLAIM NOT FOUND';
                }
                i++;
                } while (i < count);
                         
            insert tasks; 
            //Get rid of the tasks as they have IDs.                        
            tasks.clear() ;
            // nuke the whole darn thing
        PageReference home = new PageReference('/apex/HouseholdDocsReceived');        
        //home.setRedirect(true);        
        return home;
        }
        
    public PageReference save(){ 
        Integer count = cases.size();
        Integer i = 0;  
        Integer k = -1;          
            do {
                List<Opportunity> holdingpen=[SELECT id, name, accountid from opportunity where Claim_Ref__c = :cases[i].caser limit 1];
                if(holdingpen.size()==1)
                {
                        Opportunity cell=holdingpen.get(0);
                        holdingpen.clear();
                        tasks.add(new Task());
                        k++;
                        tasks[k].whatID=cell.id;
                        cases[i].policyholder=cell.name;
                        tasks[k].Subject=Subject;
                        if (Subject=='Documents Received')
                        {
                                tasks[k].description=Subject +' '+cases[i].poster;
                        }
                        else if (Subject=='TLC Rejection')
                        {	
                        		tasks[k].description='Claim has been rejected from TLC';
                        }
                        else if (Subject=='Property List')
                        {
                        		tasks[k].description='Property list has been sent to the insurer via email';
                        }
                        else
                        {
                                tasks[k].description='Correspondence sent: '+Subject +' '+cases[i].poster;
                        }
                        if (docReturns)
                        {
                                tasks[k].description='Documents returned.  '+tasks[k].description;
                        }
                        tasks[k].ownerID=UserInfo.getuserid();
                        tasks[k].status='Completed';
                        tasks[k].activitydate=system.today();
                        ID relation=[Select id from Contact where accountid= :cell.accountid limit 1].id;
                        tasks[k].whoid=relation;
                 }
                else
                {
                        //we did not find it.
                        cases[i].policyholder='CLAIM NOT FOUND';
                }
                i++;
                } while (i < count);
                         
            insert tasks; 
            //Get rid of the tasks as they have IDs.                        
            tasks.clear() ;
            // nuke the whole darn thing
            PageReference home = new PageReference('/apex/Letter_out');        
            //home.setRedirect(true);        
            return home;                    
            }  
            
    public PageReference cancel(){            
        PageReference home = new PageReference('/home/home.jsp');        
        home.setRedirect(true);        
        return home;    
    }    
    
    public PageReference outg() {
    	//This is for the page outgoing_Post
    	//Requires tasks and disbursements.
    	//Existing disbursements get loaded into this list.
    	List<Disbursement__c> costs = new List<Disbursement__c>();
    	//Disbursements that need updating get loaded into this list.
    	List<Disbursement__c> costupdates = new List<Disbursement__c>();
    	//New tasks get loaded into this list.
    	List<Task> jobs = new List<Task>();
    	//The list of case references, as a list so I can use it in a SOQL query to get the lot.
    	List<String> reflist=new List<String>();
    	//When handling each disbursement to be upserted, here is a holding item
    	Disbursement__c costitem;
    	//We need to know our record type for the disbursement
    	ID PostRecType=[SELECT id from RecordType where SObjectType='Disbursement__c' AND name='Postage' LIMIT 1].id;
    	//A boolean flag showing we found a disbursement.
    	boolean foundexisting = false;
    	//Need maps to cross-reference case refs to opportunity names for the UI
    	//Map to cross-ref accountID and case ref
    	Map<ID, String> accid2caseref = new Map<ID, String>();
    	//Need to map contactID and case ref
    	Map<String, ID> caseref2conid = new Map<String,ID>();
    	//And a map of policyholdername and case ref
    	Map<String, String> caseref2name = new Map<String,String>();
    	//And a map of opportunity ID and case ref
    	Map<String, ID> caseref2oppoid = new Map<String,ID>();
    	//Let's build the list of case refs to do the SOQL.
    	Integer count=cases.size();
    	for (caserefs itera : cases ) {
    		//Build list of case refs in the loop
    		reflist.add(itera.caser);
    	}
    	//Get the claims and disbursements.
    	List<Opportunity> pileof=[SELECT id, name, accountid, insurer_prefix__c, Claim_Ref__c, (Select id, RecordTypeId, Cost_to_ACM_variable__c, postage_type__c, Handelling_Fee__c, Cost_to_Client__c, Comments__c, Type__c From Disbursements__r) From Opportunity where claim_ref__c in :reflist];
    	//Let's decide how much this is going to be.
    	//Current costs are, 23/8/10
    	//First class letter 41p
    	//Second class letter 32p
    	decimal value=0;
    	//Set to two decimal places to make sure it look like a price.
    	value.setScale(2);
    	if (subject=='1st Class Post'){
    		//1st class
    		value=0.41;
    		if(redticket==true){
    		//Registered signed for is 74p
    		value=value+0.74;
    		}
    	} else if(subject=='2nd Class Post'){
    		//2nd class
    		value=0.32;
    		if(redticket==true){
    		//Registered signed for is 74p
    		value=value+0.74;
    		}
    	} else if(subject=='1st Class Packet'||subject=='2nd Class Packet'){
    		//Packet means looking at the supplied figures.
    		//Fallback figures are large letter lightest class.
    		if(numitems > 0 && totalcost > 0){
    			//IE they filled it in
    			value=totalcost/numitems;
    		} else {
    			//They failed.  Quite a feat as the field is required.
    			system.debug('Epic failure to provide cost/weight figures by '+ userinfo.getname());
    			value=-99;
    			//Set the value to £-99, so I can see it and Genny will query negative costs. 
    		}
    		// This section left out as RoyalMail.com OBA shows prices including registered fee
    		//if(redticket==true){
    		//Registered signed for is 74p extra on parcels
    		//value=value+0.74;
    		//}
    	//End of cost calc section.	
    	}
    	//Clear the maps ready to be refilled.
    	accid2caseref.clear();
    	caseref2name.clear();
    	caseref2oppoid.clear();
    	//Iterate rows of Opportunity
    	for (opportunity cell:pileof) {
    		//We have one opportunity with multiple disbursements.
    		//Populate the maps with ID and name information.
    		accid2caseref.put(cell.accountid, cell.claim_ref__c);
    		caseref2name.put(cell.claim_ref__c,cell.name);
    		caseref2oppoid.put(cell.claim_ref__c,cell.id);
    		//Clear old values out of disbursement table and foundexisting.
    		costs.clear();
    		foundexisting=false;
    		//Take the child query and copy into the list.
    		costs=cell.disbursements__r;
    		system.debug(cell.Claim_Ref__c);
    		system.debug(costs.size());
    		if (costs.size()>0) {
    			//Then there is a disbursement
    			//Loop through them until we find a postal one.
    			for(Disbursement__c existings : costs) {
    				if(existings.RecordTypeId==PostRecType&&existings.Postage_type__c=='Automated entries') {
    					//If we do find one, set the flag foundexisting.
    					foundexisting=true;
    					//Take the item for our list to be updated.
    					costitem=existings;
    				}
    				//Not postage, next iteration of for loop
    			}
    			//End of for loop, time to see what we found.
    		} 
    		if (foundexisting==false) {
    			//No existing disbursement found, insert here.
    			costitem=new disbursement__c(RecordTypeId=PostRecType, Postage_type__c='Automated Entries', Handelling_Fee__c=15, Disbursements__c=cell.id, Cost_to_ACM_variable__c=0, Comments__c='.', Status__c='Received');
    		}
    		//As it's boolean, not entering the if braces must mean we found one already and copied it into the costitem variable.
    		//Now we have an item to update,
    		//Increase the Cost to TCF by known amount
    		if(cell.Insurer_Prefix__c!='Royal and Sun Alliance') {
    			//RSA don't pay postage
    			costitem.Cost_to_ACM_variable__c=costitem.Cost_to_ACM_variable__c+value;
    		}
    		//Journal the item with today's date in the reason for disbursement
    		costitem.Comments__c=costitem.Comments__c+'\n Post disbursement of £'+string.valueOf(value)+' for';
    		if(redticket==true){
    			costitem.Comments__c=costitem.Comments__c+' Registered ';
    		}
    		costitem.Comments__c=costitem.Comments__c+' '+subject+' Added '+system.now()+' by '+userinfo.getName();
    		//Add our item to the stack of updates.
    		costupdates.add(costitem);
    		//Now create a logging task
    		
    		//Now update the list of items with the PH name to prove we did it
    		}
    		//End of loop of opportunities
    		//Stick our updated disbursements back into the database.
    		upsert costupdates;
    		//Now update UI variables to show, and create logging tasks.
    		//We need to query contacts using the accountid list to personalise the tasks.
    		Set<ID> accountlist = accid2caseref.keyset();
    		List<Contact> personnel = [Select ID, AccountID from Contact where AccountID in :accountlist];
    		//Now use our list to create and populate a map of caseref to contactid
    		//A holding var for contact ID and case reference and the task item to be pushed on to queue.
    		String caserf;
    		ID thiscon;
    		Task workitem=new Task();
    		//Clear the map of contact IDs to make sure there's no overlap
    		caseref2conid.clear();
    		for(Contact conlisting : personnel) {
    			//Goes through each contact found
    			caserf=accid2caseref.get(conlisting.accountID);
    			caseref2conid.put(caserf,conlisting.ID);
    		}
    		//Update loop
    		for (integer i=0; i<count; i++){
    			//Update each UI row in turn to add cost value
    			cases[i].keyser=string.valueof(value);
    			//Find the name value from the map and update UI value
    			cases[i].policyholder=caseref2name.get(cases[i].caser);
    			//Set up the task
    			workitem=new Task();
    			workitem.Status='Completed';
    			workitem.ActivityDate=system.today();
    			workitem.Subject=Subject;
    			workitem.ownerID=UserInfo.getuserid();
    			workitem.WhatId=caseref2oppoid.get(cases[i].caser);
				workitem.whoid=caseref2conid.get(cases[i].caser);
				workitem.description='Correspondence sent: '+Subject +' '+cases[i].poster;
				if (docReturns)
                        {
                                workitem.description='Documents returned.  '+workitem.description;
                        }
    			

                if(cases[i].policyholder==null) {
    				//The claim is not found, so there's no name in the pile.
    				cases[i].policyholder='CLAIM NOT FOUND';
    			}  else {
    				//The claim was found, so values are safe
    				system.debug(workitem);
    				jobs.add(workitem);
    			}
                       
    		}
    		//Now our pile is created let's insert it
                insert jobs; 
    		//finally, let's create the page reference to return, which udpates the page.
    	PageReference home = new PageReference('/apex/Outgoing_Post');        
        return home;
    }
}

 

Thanks again ...

k_bentsenk_bentsen

This is sort of a shot in the dark here, but try adding OwnerId = UserInfo.getUserId() to all the Opportunity declarations in the test class... For example:

 

Opportunity Barney = new Opportunity(Name='Flintstoned', AccountId=whom, OwnerId = UserInfo.getUserId(), Insurer_prefix__c='KGM', Insurer__c=insurer, Case_referral_type__c='Unrecovered Theft', Business_Unit__c='Motor', Claim_Ref__c='430640', StageName='Claims Support', Date_of_Loss__c=date.today(), CloseDate=date.today());

dev_sfdc401dev_sfdc401

having same issue while doing inserting on custom object.. ownerId of the custom object is set to Event object's ownerId before insert. this issue is happening rarely

Michael MeinhardtMichael Meinhardt
@k_bentsen - Good call on the OwnerId = UserInfo.getUserId()

I was duplicating attachments, and ran into this - Of course they don't give an offending field :(

Just an obvious extension - This error can affect any sObject where there is a user reference besides the ones SalesForce manages, e.g. OwnerId on Attachment is affected, while CreatedById and LastModifiedById are not affected.